我正在使用自定义查询和wp-page-navi插件。但是,当我点击第1页2 3时,它只显示第一页的内容。如何解决这个问题?在存档页面上的工作和类别。
package al.durandal.com.jsf;
@ManagedBean(name="IdToString")
@ViewScoped
public class IdToStringTypeComponent extends ManagedComponent {
/**
*
*/
private static final long serialVersionUID = -233667982117424411L;
private PackagesType packageType;
private StatusType statusType;
private static Logger logger =Logger.getLogger(IdToStringTypeComponent.class.getName());
@Autowired
private transient StatusTypeDAO statusTypeDAO;
@Autowired
private transient StatusTypeService statusTypeService;
@Autowired
private transient PackagesTypeDAO packagesTypeDAO;
public List<StatusType> listAllStatusTypes(){
return new java.util.ArrayList<StatusType>(statusTypeDAO.findAllStatusTypes());
}
public StatusType getStatusType() {
return statusType;
}
public void setSatusType(StatusType statType) {
this.statusType = statType;
}
@Transactional
public StatusType loadStatusTypeByPrimaryKey(Integer sidKey) {
statusType = statusTypeDAO.findStatusTypeByPrimaryKey(sidKey);
return statusType;
}
public String returnProductName(Integer statusCode){
statusType=statusTypeDAO.findStatusTypeByPrimaryKey(statusCode);
if(statusType!=null)
return statusType.getStatusName();
else
return "Empty";
}
public String returnPackagetName(Integer pkgCode){
packageType =packagesTypeDAO.findPackagesTypeByIdPackage(pkgCode);
if(packageType!=null)
return packageType.getName();
else
return "Not Available";
}
@Override
public void postConstruct() {
// TODO Auto-generated method stub
statusType= new StatusType();
}
public void setStatusValues(int statusId){
System.out.println("statusId "+statusId);
statusType = new StatusType();
statusType = loadStatusTypeByPrimaryKey(statusId);
System.out.println("statusType" + statusType);
System.out.println("Ja ku jam ketu");
setSatusType(statusType);
}
public int setMaxStatusType(){
int statusTypeNo=statusTypeService.countStatusTypeMax();
statusType = new StatusType();
System.out.println("statusTypeNo " +statusTypeNo);
statusType.setSid(statusTypeNo);
return statusTypeNo;
}
@Transactional
public void saveStatusType(StatusType statustype) {
logger.info("Saving Status Type: "+statustype.toString());
FacesMessage message = null;
FacesContext context = FacesContext.getCurrentInstance();
boolean save=false;
try {
//crmNotesService.saveCrmNotes(crmNotes);
statusTypeService.saveStatusType(statustype);
logger.info("Saving...");
//statustype.unset();
//statusType.setSid(statusTypeService.countStatusTypeMax());
//
//statustype.setSid(statusTypeService.countStatusTypes());
save = true;
}
catch(Exception e)
{
logger.info("FAILED during saving...");
logger.info("Excpetions are: "+e.toString());
throw e;
}
if(save) {
message = new FacesMessage(FacesMessage.SEVERITY_INFO, "OK!","Saved Succesfully !");
} else {
message = new FacesMessage(FacesMessage.SEVERITY_WARN, "Error!", "Unable to save !");
}
context.addMessage(null,message );
}
}
答案 0 :(得分:1)
自定义查询后,尝试使用wp_reset_postdata();
,如下所示:
<?php
$current_page = (get_query_var('paged')) ? get_query_var('paged') : 1; // get current page number
$args = array(
'posts_per_page' => 5, // the value from Settings > Reading by default
'paged' => $current_page // current page
);
query_posts( $args );
$wp_query->is_archive = true;
$wp_query->is_home = false;
while(have_posts()): the_post();
?>
<article class="blog-box">
<header>
<div class="row">
<div class="col-md-1 blog-date">
<span class="blog-day"><?php the_time('jS') ?> </span>
<span class="blog-month"><?php the_time('M') ?></span>
</div>
<div class="col-md-11">
<h2><?php the_title() /* post title */ ?></h2>
</div>
</div>
</header>
<?php the_post_thumbnail('blogImage', array( 'class' => "img-responsive")); ?>
<?php my_excerpt(short);?>
<a href="<?php echo get_permalink(); ?>" class="more-btn">more</a>
</article>
<!-- // blog box -->
<?php
endwhile;
if( function_exists('wp_pagenavi') ) wp_pagenavi();
wp_reset_postdata();
?>