You should be able to do this with the get_children
function (see the codex),
$ticket_id = 34; // assume you want to retried the replies of ticket post id=34
$args = array(
'post_type' => 'support_tickets',
'numberposts' => -1,
'post_parent' => $ticket_id,
'orderby' => 'date',
'order' => 'DESC' );
$replies = get_children( $args );
Assuming that your custom post support_tickets
has been registered with the attribute hierarchical
set to true (see codex).
Related Posts:
- Query by one meta_key and sort by another (possibly NULL value)
- Filter query posts by the count of metas for a meta key
- can’t get query to order posts by acf datepicker
- mySQL query. ORDER BY meta_key
- Order query by post meta value
- Order posts by custom field DATE value
- Ordering by a metadata subfield in WordPress?
- Order by title – but now built in wordpress func, sort the_title
- Querying with WP query using meta key price
- How to manage a particular “order by” for get_search_query()?
- Order terms by count – missing terms
- JetEngine Query Builder – order by value from repeater
- Order posts ascending from posts in array
- wp query multiple values > display a specific value first
- Order WordPress Query by Custom Field While Still Using Tax_query Argument
- “order” does not affect order of custom query
- Query Posts that have or don’t have a meta_value and order by the same ASC
- Apply ordering args to newly merged queried
- WP_Query orderby meta key/value suddely stopped working
- Ascending & descending posts on same page with IF statement
- Get all image from single page using this query
- Sort posts by Date (DESC) and by Title (ASC)
- simple sql query on wp_postmeta very slow
- How many WordPress SQL Queries per page?
- Compare two numeric custom fields
- Custom query filter not working on woocommerce category page
- How to delete a transient on post/page publish?
- How to extract all ID variables from a query string?
- WordPress creating excessive joins on meta_query with search
- How to display liked posts of current user in wordpress?
- Remove Unnecessary Mysql Query
- Custom Post order for homepage
- Grouping related postmeta data via SQL query
- How to remove duplicate query on page load or make them cacheable
- Slow meta_query with about 4 milion record on wp_postmeta
- wpdb::prepare() isn’t working
- How can I apply a meta query for a single custom post type in the main query?
- WP Query Sort by meta value (date)
- Disable the MySQL query in the main query
- Huge amount of queries on my site
- Using pre_get_posts to target a query in the sidebar
- Query metas (and not : query posts by metas)
- Select query for a login
- What’s wrong with my $wpdb prepare?
- How do I use get_query_var() within plguin code
- How to display related posts by same publish date?
- Get post according to current taxonomy
- Alter query with posts_clauses to retrieve NULL values last
- Query based on title, with ‘compare’ => ‘IN’
- Order by empty custom field
- wpdb print all post meta
- Issue with using add_rewrite_rule() for post querying custom fields
- Plugin will sort users by usermeta
- How to write: $wpdb->update having WHERE NOT value pair in the array
- Query posts according to specific post meta values
- wpdb COALESCE won’t work
- empty query breaks other queries
- Problem in exploding the_content to array
- Query does not return content
- What is wrong with my wp query, cant exclude the category that i want
- how to insert missing tags into the posts through mySQL?
- Query posts dynamic date range
- Parse query filter in wordpress and relation
- How to write update query in WordPress to expire transients
- Query Nickname rather than Display Name in custom Woocommerce plugin
- Get previous posts list
- how to replace old DW site with new WP site? [closed]
- WordPress SQL query to tag all posts containing a specific word on title
- Querying Advanced Custom Fields
- How to rearrange a pool of posts joined using two queries?
- wpdb update multiple row?
- List WordPress Post and Related Attachments outside of a post page
- Can I include get_posts in this array?
- Custom query Custom-Post-Types creates error
- Formatting a date/time returned from a custom $wpdb query
- Rewrite rule for query params
- Improve performance of slow query
- Hook into the Admin Dashboard and redirect users
- Displaying data from custom table
- SEO friendly query vars
- Prevent versioning for .woff (font) files
- Orderby event date (if it exists) or post date (if it doesn’t) – how to reorder posts based on meta value OR date
- Is there any way to get all custom posts and all custom terms with it’s meta in few queries?
- OR condition not working
- Query not returning child posts for any parent post ID
- Use $wpdb->get_results with filter based on array
- Add Hook for clearing transient when post is added
- Archive query not working correctly
- Custom MySQL Query for Post and Post Meta
- How to have more post in a page than in your home page
- Find all posts via SQL beginning with A of type B
- Show links to child pages on both parent AND child pages
- Modify Global Posts Plugin
- How to reference same column name but different table in custom db query
- Retrieving custom field array value through db query
- Allow admin to determine the order of queries?
- SQL Query : how copy all tags of post into their post content in wordpress by sql query
- 3 queries to update WordPress
- Query filter on custom post by current author in post widget for elementor query id
- Querying Posts from ACF Repeater Subfield Select Value