Category not being selected

The cat parameter takes an ID and not the category name or slug. If you want to use the slug you need category_name but it must be the slug. $first_query = new WP_Query(‘category_name=postblok’); Other category parameters are: cat (int) – use category id. category_name (string) – use category slug (NOT name). category__and (array) – use … Read more

How to change tag based on metabox value within $wp_query

It sounds like you’re just looking for get_post_meta(). Using your custom field of issue_number, you’ll do something like this (untested): $issue_number = get_post_meta( get_the_ID(), ‘issue_number’, true ); $my_issue_query = new WP_Query( array( ‘post_type’ => ‘issue’, ‘tag’ => ‘issue-‘ . $issue_number, ‘posts_per_page’ => 50 )); Note: While the code you pasted may work, you don’t want … Read more

Get current page term title to use in WP_Query

Do what single_term_title does and check the queried object with get_queried_object. function single_tax_slug() { $term = get_queried_object(); if ( !$term ) return; if ( is_category() ) { $term_slug = $term->slug; } elseif ( is_tag() ) { $term_slug = $term->slug; } elseif ( is_tax() ) { $term_slug = $term->slug; } return $term_slug; } $slug = single_tax_slug(); … Read more

Same post appears in related Posts?

Aahhh, it’s a typo, I guess. There is no parameter called posts__not_in. It’s called post__not_in. So you should change your code to: function dark_delight_get_related_posts(){ $post = get_post(); $args = array( ‘posts_per_page’ => 4, ‘ignore_sticky_posts’ => true, ‘post__not_in’ => array($post->ID), // post and not posts ); $categories = get_the_category(); if( !empty($categories) ){ $category = array_shift( $categories … Read more

how to use tax_query to apply both terms or one if one is empty

Change your code with the following: $args = array( ‘post_type’ => ‘property’, ‘posts_per_page’ => 5000, ); $statuses = explode( ‘,’, $st_term_final_string); $terms = explode( ‘,’, $il_term_final_string ); if ( $statuses || $terms ) { $args[‘tax_query’] = array(); if ( $statuses ) { $args[‘tax_query’][] = array( ‘taxonomy’ => ‘Status’, ‘field’ => ‘slug’, ‘terms’ => $statuses ); … Read more

WQ Query post meta date comparison

You have a bit of a problem. The only human calendar format that sorts correctly is YYYY/MM/DD, the separators are optional. You have DD/MM/YYYY. Whoever decided to store in that format made a bad decision. Your best option is to correct that design decision and convert those dates to YYYY-MM-DD or to a Unix Timestamp. … Read more