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 );