admin管理员组文章数量:1406354
I am facing very strange problem. Speaker is a custom post type and taxonomy. Target is showing all speakers which taxonomy is speaker as well.
When I am loading /speakers page, it is showing general blog posts. Also template is not same as archive-speaker.php. I have created another custom post type for testing which is working well. Only issue with speaker custom post type. It was working on another nginx server. After cloning the site to new nginx server, I see this problem.
My all configurations and testing:
register_post_type('speaker', array(
'labels' => array(
'name' => __('People', 'dxef'),
'singular_name' => __('People', 'dxef'),
'add_new' => __('Add New', 'dxef'),
'add_new_item' => __('Add New Person', 'dxef'),
'edit_item' => __('Edit Person', 'dxef'),
'new_item' => __('New Person', 'dxef'),
'all_items' => __('All People', 'dxef'),
'view_item' => __('View Person', 'dxef'),
'search_items' => __('Search People', 'dxef'),
'not_found' => __('No People found', 'dxef'),
'not_found_in_trash' => __('No People found in trash', 'dxef'),
'menu_name' => __('People', 'dxef')
),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array(
'slug' => 'speakers',
'with_front' => false
),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => true,
'menu_position' => 5,
'supports' => array(
'title',
'editor',
'thumbnail'
)
));
Loading taxonomy related customs_posts
add_action( 'pre_get_posts', 'speaker_archive' );
function speaker_archive( $query ) {
if( $query->is_main_query() && !is_admin() && is_post_type_archive( 'speaker' ) ) {
$query->set( 'posts_per_page', '30' );
$taxquery = array(
array (
'taxonomy' => 'roles',
'field' => 'slug',
'terms' => 'speaker',
'operator' => 'IN'
)
);
$query->set( 'tax_query', $taxquery );
}
}
Above code is not being called any more. is_post_type_archive( 'speaker' )
returns false on /speakers
page. I have flushed rewrite rule by saving permalinks. But it does not solve my issue.
I am assuming before calling custom post type, general blog post is being called. But not sure how to detect why such happen and what is the actual solution.
本文标签: nginxShowing another posts on Archive custom post type page
版权声明:本文标题:nginx - Showing another posts on Archive custom post type page 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744997603a2636770.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论