我已经在网上搜索过了,想找到一些解决方案,但没有一个是适合我的,有人能帮我解决这个问题并解释一下是怎么回事吗?我花了3个小时调试,没有发现问题。
这是我的代码:
global $paged;
global $wp_query;
wp_reset_query();
$per_page = get_option(\'posts_per_page\');
$cat_cars = get_term_by(\'slug\', \'cars\', \'category\');
$page_links_total = ceil($cat_cars->count / $per_page);
$paged = (get_query_var(\'paged\')) ? get_query_var(\'paged\') : 1;
$args = array(
\'post_type\' => \'cars\',
\'post_status\' => \'publish\',
\'cat\' => $cat_cars->term_id,
\'orderby\' => \'date\',
\'order\' => \'DESC\',
\'posts_per_page\' => $per_page,
\'paged\' => $paged
);
$page_links = paginate_links(array(
\'base\' => add_query_arg(\'paged\', \'%#%\'),
\'format\' => \'\',
\'prev_text\' => __(\'«\'),
\'next_text\' => __(\'»\'),
\'end_size\' => 2,
\'mid_size\' => 1,
\'type\' => \'plain\',
\'total\' => $page_links_total,
\'current\' => $paged
));
$car_query = new WP_Query($args);
然后我打电话
have_posts
,
the_post
, 等等<这部分工作正常,直到我转到分页的第二页,却什么也找不到。