Of course it is possible. All you have to do is to set post_parent
argument to 0
.
function remove_children_from_archive( $query ) {
if ( ! is_admin() && $query->is_main_query() && is_post_type_archive('my_custom_post_type') ) {
// of course you'll have to change my_custom_post_type to real slug - probably services
$query->set( 'post_parent', 0 );
}
}
add_action( 'pre_get_posts', 'remove_children_from_archive' );
Related Posts:
- What does this PHP function code mean? [closed]
- Get the ID of the latest post
- Change permalinks for posts but not for custom post types
- Front end post editing using a form
- Set posts of a custom post type to be private by default?
- How make get_next_post() return first post when viewing last one
- post_row_actions for custom post type
- modify all posts of a category to “no comments allowed”
- Getting a div content of a post in wordpress?
- How can I add dropdown widget/box to admin post page?
- Custom permalinks – post type – hierarchical taxonomy’s
- How to show related posts by category or custom post type?
- Downsides to not using built-in “Posts” post type?
- ascending order custom post type
- add_meta_box: Datepicker like the one for postdate?
- [Plugin: Posts 2 Posts] Changing display order of connections
- Display taxonomy term only if there’s a value
- How to show post title outside of loop? [closed]
- How do you use JavaScript to detect the homepage
- How to delete all posts from a custom post type?
- Update content of multiple pages/posts at once?
- Display types of posts in edit.php instead of All, Published, Scheduled and Draft
- CPT’s archive and single page not working [closed]
- Custom Taxonomy – Tags Metabox is showing instead of Categories
- How to post twitter like updates on wordpress
- Trying to edit the single page from a Custom Post
- How to Submit Post Via cURL & PHP
- apply filters only to specific post listing without check the url parameters
- How Can I Set the Post Author of a Post I Just Created With PHP?
- WordPress Orderby Numeric Value Not Working
- Deleting Custom Post type data using mySQL command
- Notice: Undefined index: suppress_filters
- How to add post_type=value when editing that post type in the WordPress admin?
- Storing posts from query and accessing later via AJAX call
- If post has custom field then display css-class
- Missing Posts in Custom Taxonomy List
- How can i add thumbnails images to particular post (using code not admin pannel) in wordpress
- Showing posts from different categories and from custom post type
- custom post type category count shortcode
- Add post location with mile radius allowing search
- Custom Post Slug same as Parents Category Slug
- How to integrate a form (Ninja Form or Contact Form 7) with Custom Post Types?
- Prioritize posts in query by meta keys?
- Homepage’s content is dependent on the custom field values (set automatically), how do I get homepage to update without manually updating page?
- How to get all tags of a custom post type by id
- How to define which register_post_status goes to which register_post_type?
- Create new custom post and post category of same name
- Load Next WordPress Posts With AJAX?
- If there is only one post (show elements) else (show other elements)
- Custom post type menu
- wordpress lists similar type of posts in a custom post type
- Modify Posts from Custom_Post_Type within the plugin
- How do I edit the WordPress post.php file?
- Posts are not rendering perfectly [closed]
- How I can made a custom post type to page templates?
- List all posts in taxonomy term
- list posts of two post types in a single template
- how to redirect to a custom post template
- Post/Custom Post Type URL Access
- Front-end Image Upload to Custom Meta Box
- Adding /blog in front of single posts (only)
- Add a form in every post and save data in post meta
- list articles in admin showing nested categories or slugs?
- Search CPT by tag ids
- Post template with breadcrumb needs to show page navigated from
- Define multiple prefixes for custom post type
- Publishing failed. The response is not a valid JSON response
- add all blog posts to folder
- Correct way adding External classes to Custom Post type and output their methods to template
- Show posts from WP Custom Post Type selected from a field in a metabox
- order custom post type posts by custom date
- How to show posts of the same category on a page?
- Assign a Post to a User
- Cannot save pages after migration
- custom post type to post association in wordpress
- Rest Api not working with Iframe in form data
- Need to display author’s email id in the “Edit post” field in wp dashboard. How do I do this?
- Use WP pagination functions on a custom page template
- How to get all posts related to a taxonomy?
- call a function when insert and update a custom post type
- Work and Display a Custom Post Type as a normal Post
- Most efficient way of showing children posts?
- Limit or filter edit view in the dashboard to a specific ID only?
- Custom post type with two templates
- One Post with different content, depending on a Page
- Custom Post Type
- Popup panel is only displaying 1 entry ignoring all others
- Custom Post Status & Taxonomies
- How to display data with pagaination on backend?
- Edit post meta direct from post.php?
- How to Arrange Support => Thumbnail
- Front-end form submission not creating post
- Post being scheduled that shouldnt be schedulded
- Post type cloud like tag cloud?
- Change permalinks for posts but not custom post type?
- Get custom post type parent category
- How to delete unnecessary custom post types in the UI
- show the most recent date of all posts to display on front end
- Error 403 when posting comments to a custom post type from a different page
- Two pagination in one page without AJAX