WP Job Manager plugin – Listing only the twelve job categories on frontpage order by jobs they have

Edited: This is a much simpler version of what you are looking to do. You don’t need WP_Query(). You can use a foreach loop and an iterator: <?php echo ‘<ul class=”job-category-list”>’; // Get the terms and order them by count in descending order. $terms = get_terms( [ ‘taxonomy’ => ‘job_listing_category’, ‘orderby’ => ‘count’, ‘order’ => … Read more

exclude product with available tag

You can setup a tax_query with the NOT IN operator. WP_Query( array( ‘post_type’ => ‘product’, ‘posts_per_page’ => 500, ‘tax_query’ => array( ‘relation’ => ‘AND’ array( ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘slug’, ‘terms’ => array( ‘cars’ ), ), array( ‘taxonomy’ => ‘product_tag’, ‘field’ => ‘slug’, ‘terms’ => array( ‘whatever_tag_i_dont_need’ ), ‘operator’ => ‘NOT IN’, ), ), … Read more

wp_query is showing posts from other categories

I have used Custom Select Query to gather all information in a single call and hope it may work out. global $wpdb; $selected_cat_id = ‘6,7,8,9’; $post_count = 5; $custom_query = “SELECT $wpdb->posts.ID, $wpdb->posts.post_title, $wpdb->terms.name FROM $wpdb->posts LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) LEFT JOIN $wpdb->terms ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->terms.term_id) WHERE 1=1 AND ($wpdb->term_relationships.term_taxonomy_id IN … Read more

Order by meta_key doesn’t work

Current Query $args = array( ‘post_type’ => ‘brands’, ‘meta_query’ => array( array( ‘key’ => ‘br_type’, ‘value’ => ‘Aviation’ ), array( ‘key’ => ‘br_category’ ), array( ‘key’ => ‘br_name’ ) ), ‘posts_per_page’ => -1, ‘orderby’ => [ ‘br_category’ => ‘ASC’, ‘br_name’ => ‘ASC’ ], ‘order’ => ‘ASC’, ‘fields’ => ‘ids’ ); produce this SQL query ‘SELECT … Read more

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