admin管理员组文章数量:1426648
I have a CPT created, in my CPT file page the father pages and daughter pages are shown.
Books of science
Book 1
Book 2
Books of science fiction
Book 1
Book 2
In my case I don't want it to be like that, since I want to show the daughter pages only inside the father page.
How can I make the page file only show the father pages and not the daughters?
This is my CPT file template currently:
<?php
//* Force full-width-content layout
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
remove_action('genesis_loop', 'genesis_do_loop');
//* New loop
add_action('genesis_loop', 'b_custom_loop');
function b_custom_loop() {
global $wp_query;
$args = array(
'post_type' => 'b_books',
'order' => 'ASC',
'orderby' => 'date',
'posts_per_page' => 10
);
genesis_custom_loop( $args );
}
Is that possible?
I have a CPT created, in my CPT file page the father pages and daughter pages are shown.
Books of science
Book 1
Book 2
Books of science fiction
Book 1
Book 2
In my case I don't want it to be like that, since I want to show the daughter pages only inside the father page.
How can I make the page file only show the father pages and not the daughters?
This is my CPT file template currently:
<?php
//* Force full-width-content layout
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
remove_action('genesis_loop', 'genesis_do_loop');
//* New loop
add_action('genesis_loop', 'b_custom_loop');
function b_custom_loop() {
global $wp_query;
$args = array(
'post_type' => 'b_books',
'order' => 'ASC',
'orderby' => 'date',
'posts_per_page' => 10
);
genesis_custom_loop( $args );
}
Is that possible?
Share Improve this question edited Jun 14, 2019 at 11:26 Marifer Villarroel asked Jun 14, 2019 at 10:56 Marifer VillarroelMarifer Villarroel 276 bronze badges 2- You're going to need to share the code you're using to display what you already have. – Jacob Peattie Commented Jun 14, 2019 at 11:00
- Hi Jacob, I just updated my question. – Marifer Villarroel Commented Jun 14, 2019 at 11:26
1 Answer
Reset to default 0Your can use post_parent
parameter for your query.
Ref: https://codex.wordpress/Class_Reference/WP_Query
This will change your query to:
$args = array(
'post_type' => 'b_books',
'order' => 'ASC',
'orderby' => 'date',
'posts_per_page' => 10,
'post_parent' => 0
);
genesis_custom_loop( $args );
本文标签: custom post typesDo not show child pages within a file page
版权声明:本文标题:custom post types - Do not show child pages within a file page 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745402808a2657114.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论