Get post and its children with WP_Query

The question that is similar to your question, i took sample code from there. you can replace ‘post_parent with this. global $post; $args = [ ‘wpse_include_parent’ => true, ‘post_parent’ => wp_get_post_parent_id( $post->ID ), ‘post_type’ => ‘post’ // Add additional arguments ]; $q = new WP_Query( $args ); This code will get the parents post id … Read more

Apply query arguments after the nth post

Sure! There are tons of parameters for WP-Query that can probably do what you want. Offset is usually used when your data is ordered. So if you want to ignore the two most recent ones you need to order it by date descending first, then set offset = 2. It doesn’t matter if you apply … Read more

has_excerpt() not working inside wp_query

So we already resolved the issue via the comments, but I thought I should explain something: has_excerpt() returns ! empty( $post->post_excerpt ) if the post has a custom/manual excerpt, so if the function is returning true when it should be false, then it’s likely because the length of the excerpt in the database is > … Read more

Especific order by Custom Field Values in WP_Query

First remove the order section from your args, also add nested meta_queries like the following example: $args_com_subset = array( ‘posts_per_page’ => -1, ‘post_type’ => ‘company’, ‘meta_key’ => ‘company_tiers’, ‘meta_query’ => array( ‘relation’ => ‘AND’, array( ‘key’ => ‘company_tiers’, ‘value’ => array( 1,2,3,4 ), ‘compare’ => ‘IN’, ), array( ‘relation’ => ‘OR’, array( ‘key’ => ‘company_type’, … Read more