WordPress query with items from more than one selfdefined taxonomy as `term` argument

I managed to do it. I used the following query parameter: ‘tax_query’ => array( array(‘taxonomy’ => ‘wpccategories’, ‘field’ => ‘slug’, ‘terms’ => $termz ) ) With $termz being: $termz = wp_get_object_terms($id, ‘wpccategories’, array(“fields” => “slugs”)); The problem I struggled with was that I needed to use singular ‘field’with singular ‘slug’ in the tax_query (I knew … Read more

Help ordering Post loop by two meta values

If you’re using WordPress 4.2 or newer then you can do the following: $args = array( ‘post_type’ => ‘events’, ‘posts_per_page’ => 10, ‘meta_query’ => array( ‘relation’ => ‘AND’, ‘start_date_clause’ => array( ‘key’ => ‘start_date’, ‘compare’ => ‘EXISTS’, ), ‘ticket_status_order_clause’ => array( ‘key’ => ‘ticket_status_order’, ‘compare’ => ‘EXISTS’, ), ), ‘order_by’ => array( ‘start_date_clause’ => ‘ASC’, … Read more

Combining categories (Query posts with multiple taxonomy terms)

This type of behavior is documented in the WP_Query documentation. You can use a comma-separated list of category IDs instead of just one. For example (ripped right off the Codex page): $query = new WP_Query( array( ‘cat’ => ‘2,6,17,38’ ) ); With tags it’s a little different, but not too much so: $query = new … Read more

querying data via $wpdb and get_row

Try this. $query = “SELECT * FROM wp_cf7dbplugin_submits a,wp_cf7dbplugin_submits b WHERE a.field_name=”Buyer” AND a.field_value = 1 AND a.submit_time = b.submit_time AND b.field_name = carbrand AND b.field_value=”Mercedes””; global $wpdb; // return the number of rows found $results = $wpdb->num_rows($query); var_dump($results);