该查询适用于默认日志和页面,但不适用于自定义日志存档。我错过什么了吗?
$paged_bottom = (get_query_var(\'paged\')) ? absint(get_query_var(\'paged\')) : 1;
$args_pagination_bottom = array(
\'format\' => \'?paged=%#%\',
\'current\' => intval($paged_bottom),
\'total\' => intval($GLOBALS[\'wp_query\']->max_num_pages),
\'mid_size\' => 2,
\'prev_text\' => \'<i class="fa fa-arrow-left"></i>\',
\'next_text\' => \'<i class="fa fa-arrow-right"></i>\',
);
echo paginate_links($args_pagination_bottom);
我试过这个
public function __construct()
{
add_action( \'pre_get_posts\', array($this, \'ggowl_archive_posts_per_page\'),20,1 );
}
public function ggowl_archive_posts_per_page( $query ) {
// var_dump($query);
if ( $query->is_archive(\'product\') || $query->is_category() ) {
set_query_var(\'posts_per_page\', 1);
}
}
这在课堂外有效。我怎样才能让它在课堂上发挥作用?