Php 分页不';t在wordpress页面上工作
我制作了一个显示帖子的页面,但没有显示分页(1、2、3等) 代码如下:Php 分页不';t在wordpress页面上工作,php,wordpress,pagination,Php,Wordpress,Pagination,我制作了一个显示帖子的页面,但没有显示分页(1、2、3等) 代码如下: <div class="browse-content"> <div class="container"> <h2><?php echo wp_count_posts()->publish; ?> Movies Found</h2> <section> <div class="ro
<div class="browse-content">
<div class="container">
<h2><?php echo wp_count_posts()->publish; ?> Movies Found</h2>
<section>
<div class="row">
<ul>
<?php
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args = array(
'posts_per_page' => 3,
'paged' => $paged
);
$the_query = new WP_Query( $args );
?>
<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
<?php include '_includes/items/item_2.php';?>
<?php endwhile; wp_reset_postdata();?>
</ul>
</div>
</section>
<div class="pagination"><?php novavideo_theme_pagination(); ?></div><!-- .pagination -->
</div>
</div>
</div>
找到电影
我找遍了所有地方,但没有找到答案
有人能帮我吗?
<?php
$args = array( 'posts_per_page' => 20 );
$the_query = new WP_Query( $args );?>
<?php if ( $the_query->have_posts() ) : ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<li>
<h4><a class="text_aktualnosci" href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<span class="data_dodania_arch"><?php _e('Data dodania: '); ?><strong><?php echo get_the_date(); ?></strong></span>
</h4>
</li>
<?php endwhile; ?><!-- end of the loop -->
<!-- put pagination functions here -->
<?php else: ?>
<p></p>
<?php endif; ?>
我认为更好的方法是使用函数novavideo\u theme\u pagination($pages='',$range=4){
$showitems=($range*2)+1;
全球$paged;
如果(空($paged))$paged=1;
如果($pages=='')
{
全局$wp_查询;
$pages=$wp\u query->max\u num\u pages;
如果(!$页)
{
$pages=1;
}
}
如果(1!=$pages)
{
回显“- 页面”$paged.“$pages.”中的“
- 页面” ”; 如果($paged>2&&$paged>$range+1&&$showitems<$pages)回显“”; 如果($paged>1&&$showitems<$pages)回显“”;
对于($i=1;$i=$paged+$range+1 | |$i将这两行添加到主题的function.php文件中,所有内容都将恢复工作:add_filter(‘redirect_canonical’,’custom_disable_redirect_canonical’); function custom_disable_redirect_canonical($redirect_url) {if (is_paged() && is_singular()) $redirect_url = false; return $redirect_url; }
您可以检查当前的
和post ID
。请共享用于此功能的代码:novavideo\u theme\u pagination();post ID=>paged*posts\u per\u page
add_filter(‘redirect_canonical’,’custom_disable_redirect_canonical’); function custom_disable_redirect_canonical($redirect_url) {if (is_paged() && is_singular()) $redirect_url = false; return $redirect_url; }