php-创世纪儿童主题的自定义帖子类型分页
作者:互联网
有没有可能在Genesis子主题中实现自定义帖子类型的分页,我正在使用Genesis:2.0.2,而Wordpress版本是:4.0.
我在模板中尝试了以下代码,但不适用于我.
<?php echo genesis_posts_nav(); ?>
而且我的常规类别分页在我的创世纪儿童主题中也不起作用.
<?php echo genesis_posts_nav(); ?>
我的自定义模板代码在这里:
<?php
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'sk_do_loop' );
function sk_do_loop(){
$args_spotlight_latest = array('posts_per_page' => 5,'post_type' => 'spotlight', 'post_status'=>'publish','meta_key' => 'featured_slider','meta_value' => 'true');
$spotlight_posts_latest = new WP_Query($args_spotlight_latest);
/** Content Area **/
if($spotlight_posts_latest->have_posts()){
while($spotlight_posts_latest->have_posts()){
$spotlight_posts_latest->the_post();
$feat_image = wp_get_attachment_url(get_post_thumbnail_id());
..............
..............
..............
}
}
genesis_posts_nav();
}
?>
谁能帮我这个忙.
提前致谢.
解决方法:
使用此代码,它将可以正常工作,并与静态页面有关
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'sk_do_loop' );
function sk_do_loop(){
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args_spotlight_latest = array('posts_per_page' => 5,'post_type' => 'spotlight', 'paged' => $paged);
$spotlight_posts_latest = new WP_Query($args_spotlight_latest);
/** Content Area **/
if($spotlight_posts_latest->have_posts()){
while($spotlight_posts_latest->have_posts()){
$spotlight_posts_latest->the_post();
echo "<h1>".the_title()."</h1>";
the_content();
}
previous_posts_link( '« Newer' );
next_posts_link( 'Older »', $spotlight_posts_latest->max_num_pages );
}
}
标签:custom-post-type,pagination,genesis,wordpress,php 来源: https://codeday.me/bug/20191121/2050716.html