[英]Wordpress Pagination is not working anymore in my custom page
我对本机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();?>
注意:“ numberposts”和“ posts_per_page”可以互换使用。 我认为您一次不能使用它们两者。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.