It is correct behavior. And the reason for this problem is pretty simple…
When you use tag
param in WP_Query
, then it searches for tags with given slug (string used in URLs) – so there should be no spaces. There are 7 parameters for slug searching in WP_Query:
- tag (string) – use tag slug.
- tag_id (int) – use tag id.
- tag__and (array) – use tag ids.
- tag__in (array) – use tag ids.
- tag__not_in (array) – use tag ids.
- tag_slug__and (array) – use tag slugs.
- tag_slug__in (array) – use tag slugs.
As you can see none of above takes name as value.
If you want to search for tag name, then you should use tax_query
:
...
'tax_query' => array(
array( 'taxonomy' => 'post_tag', 'field' => 'name', 'terms' => $value )
)
Related Posts:
- Posts with at least 3 tags of a list of tags
- Get post count of current loop when using multiple queries on one page
- Display products from specific category in shop page
- How to uniquely identify queries?
- Use WP_Query with a custom SQL query
- Pagination not working for Custom search form & custom result template
- How to use filter hook posts_join for querying taxonomy terms in posts_where?
- Looping through tabular data
- Using next/previous_posts_link with customised search
- How to display most recent posts that haven’t already been displayed with WP_Query?
- What is the difference between these two custom queries?
- How to create/modfiy WP_Query to search in post title OR custom field?
- Display featured products through custom loop in WooCommerce 3 [closed]
- How to detect custom query inside `posts_where` hook?
- Is temporarily overwriting $wp_query a bad idea?
- Array Chunks and Inserting Varying HTML in WP_Query
- Filter user list that meta_value is empty
- Query wp_usermeta alongside wp_users
- Understanding the use of wp_reset_query();
- How to output different posts per page?
- Multiple WP_Query loops with Pagination Not Working
- WordPress posts per page WP_Query
- WooCommerce Only OnSale Products Loop Snippet [closed]
- Modifying the Search Results
- WP_Query times out
- ACF – Get lowest & highest value from field
- What format does the meta_query TIME type require?
- Offset Page Loops and Pagination
- How to find a post id using the post_excerpt?
- wp_query add arguments using array_push if variable met
- tax_query: Order by slug?
- WP_Query date_query – Use unix timestamp?
- reducing the amount of wp_query calls
- WP_Query filter and order by meta ordering by wrong joined table
- WP_Query last five posts, simply ordered by meta_value
- How to display specific posts with WP_Query?
- WP_Query “OR”: Find posts by ID, Name or Post Title?
- What is the random string I am seeing when I use get_query_var?
- Querying on multiple taxonomies pulled from $_GET checkbox array not working?
- Querying A Post That Includes Two Taxonomies Using JSON Rest API
- WP_Query condition affects posts_per_page count
- WP_Query order result by date AND meta_value
- Order by title without taking into account ‘the’
- Set global $wp_query/$post variable for dynamic page generation
- Display tags with random thumbnail from selection of posts with that tag
- How to store and receive variables in WP sessions?
- Add posts to WP Query object
- How to list posts with disabled/closed comments, with pagination?
- Category ‘pad_counts’ & ‘parent’ conflict
- WP User Query with Custom Fields and Search Results
- Order or Orderby in tax_query (How to define order of terms in WP_Query)
- Wp_query with 2 meta keys and array of meta values
- How to exclude Sticky from Recent Post?
- Display if author page is author page of current user
- Create a loop on my pages with new “WP_Query”
- WP_Query order by not working properly due to category I believe
- get_query_var always returns the default value
- WP ForLoop to compare meta information of posts to determine what post to display
- Modify WP_Query using pre_get_posts but only for frontend query?
- Multiple wp_query on archive page
- When listing child pages run out of memory
- Function to retrieve IDs of posts, cache results, and improve wp_query
- parse_tax_query causing Navigation Menu To Disappear
- WP_query is not returning the expected result
- the_post_thumbnail do 2 queries. How to optimize
- wp query meta value is not null
- Trying to use WP_Query to display a custom post type
- Search.php – return number of results but cannot loop through
- Creating ‘posts page’ loop based on the page itself
- How to get pages of parent (non-recursive)?
- WP_Query and pagination AGAIN?
- Can’t get term id for category archive
- Combine query in WP_User_Query()
- Nearby locations using Advanced custom fields, maps?
- How to display the category dropdown auto search list when key press?
- order by post date and modified date posts both in wpquery
- How to get_comments() ordered by date and parent?
- WPQuery loop not giving expected output
- WP Query filters active on wrong query
- Not able to fetch woocommerce variation sales products for particular category products
- Global page ID variable empty error
- WordPress tax_query ignoring relation OR
- pagination functions are not working
- Gather same custom field values in one value in a select tag with wp_query
- Meta key in wp_query bug?
- Order Posts By Youtube Views
- WP Query with sticky posts and tax_query
- How can I create another instance of my custom shortcode
- Declare inline background image in functions.php
- WP_Query for attachments without duplicating post_parent and displaying tagged image
- Looking for a way to exclude frontpage and nav menu from query filter
- Query posts by custom fields
- Showing posts from 4 categories along with all latest posts
- Searching in specific custom post type
- WP Query Obj: Set value to be unequal | Hide media by admin
- WordPress pagination returns the same posts
- How can I get taxonomy term name using term slug & post ID using build in WordPress function or class?
- Why does wp_query only display the most recent post when using order ASC?
- new WP_Query with order args – no more distinction between categories
- How to make OR condition in WP_Query