最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

pagination - Why next_posts(); function does not work inside header.php?

programmeradmin0浏览0评论

Why does next_posts(); function does not work inside header.php whereas it ^does work^ inside temlate-homepage.php ? My code below:

<?php

// Query ALL posts ordered by random

$args = array(

'post_type' => array('projekt'), // Posts

'orderby' => 'rand', // Order random

'posts_per_page' => 8, // get all posts

'ignore_sticky_posts' => true, // Do not preserve order of stickies

);

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

$the_query = new WP_Query( $args );

echo next_posts();

?>

....even when I add a parameter like 'max_num_pages' to next_posts(); function -> it does not work in ^header.php^

...it seems like get_header(); command has something to do with it, because when I paste the whole header.php code inside template-homepage.php then next_posts() works properly which means if I'm on /page/3/ -> next_posts() will return /page/4/ url...

发布评论

评论列表(0)

  1. 暂无评论