是否有可能在中实现自定义帖子类型的分页Genesis 儿童主题,我正在使用Genesis : 2.0.2和Wordpress 版本为:4.0。
我在模板中尝试了以下代码,但它对我无效。
<?php echo genesis_posts_nav(); ?>
在我的创世记儿童主题中,我的常规类别分页也不适用。
<?php echo genesis_posts_nav(); ?>
My Custom Template Code Here :
<?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();
}
?>
有人能帮我吗。
提前谢谢。
最合适的回答,由SO网友:Chinmoy Kumar Paul 整理而成
EDIT
Try this code:
remove_action( \'genesis_loop\', \'genesis_do_loop\' );
add_action( \'genesis_loop\', \'sk_do_loop\' );
function sk_do_loop(){
global $wp_query;
$temp_query = $wp_query;
// Fix for the WordPress 3.0 "paged" bug.
$paged = 1;
if ( get_query_var( \'paged\' ) ) { $paged = get_query_var( \'paged\' ); }
if ( get_query_var( \'page\' ) ) { $paged = get_query_var( \'page\' ); }
$paged = intval( $paged );
$args_spotlight_latest = array(\'posts_per_page\' => 5,\'post_type\' => \'spotlight\', \'post_status\'=>\'publish\',\'meta_key\' => \'featured_slider\',\'meta_value\' => \'true\', \'paged\' => $paged);
$spotlight_posts_latest = new WP_Query($args_spotlight_latest);
$wp_query = $spotlight_posts_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();
wp_reset_query();
}