So after reading through the codex, I came across the pre_get_posts
hook, and I decided to try changing the query with it, which worked for me. Not sure if it is the best way though.
For anyone that is interested here is what I did:
add_action('pre_get_posts', 'get_grandchildren' );
function get_grandchildren() {
if ( isset( $_GET['child_of'] ) ) {
//Make a custom loop which selects the id of grandchildren of parents and puts them in an array and then
set_query_var('post__in', $childrenArray );
}
}
Related Posts:
- Adding ‘menu order’ column to custom post type admin screen
- Style custom columns in admin panels (especially to adjust column cell widths)
- How do I set the default admin sort order for a custom post type to a custom column?
- Replacing the title in admin list table
- Make custom column sortable
- Custom sortable columns ordered by meta-value?
- Add “Last Edited by” column to custom post type list table
- How to add custom columns to Custom Post Type admin screen
- Column sorting with emtpy meta values
- manage posts custom column is not populating data from meta boxes
- Custom admin columns for ALL custom post types
- order of date column in custom post type
- Add custom column to custom post type overview in backend
- custom sortable column
- Custom Post Type, Two categories, Two columns with Pagination
- Replacing the title in admin list table
- Remove Post Page “View Post” Link
- How can I add columns to custom post tables
- Custom Post Types: Custom columns with Title submenu?
- How to show custom (checkbox) field value in admin post list?
- Adding menu_order to CPT admin page
- Custom post admin filtering by post meta (the date)
- Admin Column Text Positioning
- How do I sort a custom post type admin column using two meta keys?
- Add Post Url to Manage Edit Screen
- Problem adding column to WC Subscription [closed]
- how to check if custom post type column already exists?
- Adding HTML tags or css classes to admin columns
- Extending AZIndex plugin to use custom post types and custom taxonomies
- WP CPT Custom Sortable Column in Admin Dashboard Sort Order Random
- How to show first name and last name in custom post type columns
- Order a custom post type admin screen by a second custom post type title
- 4 column-loop ordered alphabetically with entries grouped (and labeled) by their first letter
- Custom columns doesn’t appear in custom post type
- How can I use this code on a custom database table?
- Problem with $post_id object’s property
- Pods CMS: How to add custom column to Adnvanced Content Type
- CPT Columns doesn’t show categories
- Getting post attchment URL to populate a CPT Admin Page Column
- Custom Columns for Custom Post Type Manager
- Make a custom column sortable by a value from a different custom post type
- Sorting custom post types in edit.php : Post disappear
- Custom sortable column with WPAlchemy
- Remove filter and view options from custom post type edit screen
- Sortable column with custom data by date
- Add Content Column to Custom Post Type backend
- Hide Published text from custom post types column
- custom filtering admin columns
- Custom sorting in post columns by ACF Pro Select Field
- Columns depending on posts count
- Making my custom column sortable
- Default custom column to off
- Change column of row action (Quick Edit) links in WP_List_Table
- Make custom post type column sortable
- Split custom post list into two columns
- How to rename default posts-type Posts
- Multiple Paginations on one Page
- Showing current taxonomy terms
- Posts to expire (deleted) after a date
- Custom Post Types Not acknowledged for date.php template
- What is the impact if i ignore title and content in my custom post types CPT?
- Why would this IF statement not work? [closed]
- Shortcode doesn’t display in custom post type
- Linking to the most recent post in a Custom Post Type
- Custom Post Type permalink shows wrong page: homepage/index.php
- Changing custom type name hides the posts
- Problem with displaying posts in the CPT category
- Hierarchial Custom Post Types/Taxonomies
- Query based on custom fields start and end date
- Create a permalink structure with custom taxonomies and custom post types gives 404
- DIsplaying URL of custom field in last post of certain taxonomy && post type
- How to change “post_class()” for a custom post type?
- Custom post type menu-icon not showing up
- Using page slug in wp_query
- Assign post type to many users
- Meta box values not displaying in Post Edit Screen after save
- Problems with custom post type
- Display list of custom post type which match taxonomy
- Sort results without WP_QUERY?
- What happens to my older posts if I switch to a child theme?
- Update custom field value
- show most viewed posts of last days by link?
- Get Posts List of Current Selected Custom Taxonomy in Shortcode
- Define a page to show custom post type
- check if current page is a child of a specified top level page
- How can I use javascript in specific posts without relying on a plugin?
- Custom Post Types – trying to make “title” display
- pricefilter without WooCommerce
- Send email to author of the post when the custom post status changes to published
- filter post by date selected in a dropdown in realtime
- Custom post type that lets users create a set of posts?
- Iterating over custom post type archive returns incorrect first ID
- Repeatable custom meta select boxes
- Getting (Invalid) when adding custom taxonomy of custom post type link in menu [closed]
- Display custom taxonomy posts of custom post types
- Custom Post type field don’t show in single machine
- ACF Field to set Publish Date – Post Duplication upon Update
- Is it possible to make is_category() recursive?
- Get X posts with the same terms as the current post (custom post type and custom taxonomy)
- WP Query – Can’t get posts with specific taxonomy