我有这个自定义帖子概述"博客"对于本机wordpress系统的所有帖子。到目前为止,一切都很好,但分页不起作用。我真的不明白它为什么不起作用。你能救我吗?
<?php
//adhere to paging rules
if ( get_query_var('paged') ) {
$paged = get_query_var('paged');
} elseif ( get_query_var('page') ) { // applies when this page template is used as a static homepage in WP3+
$paged = get_query_var('page');
} else {
$paged = 1;
}
echo("$paged " . $paged);
$posts_per_page = get_post_meta(get_the_ID(),'number_of_items',true);
if (!$posts_per_page) {
$posts_per_page = get_option('posts_per_page');
}
echo("$posts_per_page " . $posts_per_page);
global $query_string;
$args = array(
'numberposts' => '',
'posts_per_page' => $posts_per_page,
'offset' => 0,
'cat' => '',
'orderby' => 'date',
'order' => 'DESC',
'include' => '',
'exclude' => '',
'meta_key' => '',
'meta_value' => '',
'post_type' => 'post',
'post_mime_type' => '',
'post_parent' => '',
'paged' => $paged,
'post_status' => 'publish'
);
query_posts( $args );
?>
<div class="container page-content blog">
<div class="row">
<div class="col-lg-1 col-md-1 col-sm-12 col-xs-12"></div>
<div class="col-lg-10 col-md-10 col-sm-12 col-xs-12">
<h1 style=" background-color: white; padding: 1%; padding-left: 16%; "> Unsere Referenzen / verkaufte Objekte:</h1>
<?php
if ( have_posts() ) :
// Start the Loop.
while ( have_posts() ) : the_post();?>
<div style="padding: 5%; padding-left: 18%; padding-bottom: 0%; " id="post-<?php the_ID(); ?>" <?php post_class("box-container"); ?>>
<?php the_title( '<h2 style="font-size: 22px !Important" class="post-title">' ); ?>
</h2>
<h2 style="font-size: 20px !Important">
VERKAUFT
</h2>
<?php realto_post_thumbnail();?>
<?php if($post->post_content != "") {echo"<h2 style='font-size: 22px !Important; padding-top:30px;' class='post-title'> Kundenrezension: </h2>";} ?>
<div style="padding-top:10px; padding-left:0px;" class="padding30">
<?php /*the_excerpt();*/ the_content(); ?>
</div>
</div>
<?php
endwhile;
// Previous/next post navigation.
nt_pagination();
wp_reset_query();
else :
// If no content, include the "No posts found" template.
get_template_part( 'content', 'none' );
endif;
?>
</div>
<div class="container">
<div class="row">
<?php while(have_posts()):the_post(); ?>
<div style="padding: 5%; padding-left: 18%; padding-bottom: 0%; " id="post-<?php the_ID(); ?>"
<?php post_class("box-container"); ?>>
<?php the_content(); ?>
</div>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
</div>
</div>
</div>
<!-- .row -->
<!-- Page Content -->
</div>
<!-- .container -->
<?php get_footer();?>
答案 0 :(得分:0)
注意:'numberposts'和'posts_per_page'可以互换使用。 我想你不能一次同时使用它们。