Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //pre_get_posts filter is called before WordPress gets posts
- add_filter( 'pre_get_posts', 'my_get_posts' );
- function my_get_posts( $query ) {
- //if page is an archive and post_parent is not set and post_type is the post type in question
- if ( is_archive() && false == $query->query_vars['post_parent'] && $query->query_vars['post_type'] == 'my_post_type')
- //set post_parent to 0, which is the default post_parent for top level posts
- $query->set( 'post_parent', 0 );
- return $query;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement