This is because you are not passing the parameters in the correct way, taxonomy param needs to be passed under tax_query
. Please replace the $args
with the below:–
$args = array(
'posts_per_page' => 4,
'tax_query' => array(
array(
'taxonomy' => 'tag',
'field' => 'slug',
'terms' => 'pp'
)
)
);
For more details check the codex
Related Posts:
- WP_Query vs get_posts
- Magazine style frontpage with multiple categories/loops and no duplicate posts
- Ordering Posts by parent category, name ascending
- When should you use WP_Query vs query_posts() vs get_posts()?
- When to use WP_query(), query_posts() and pre_get_posts
- Some doubts about how the main query and the custom query works in this custom theme?
- Order posts by ID in the given order
- get_template_part in for loop
- How-to exclude terms from the main query the most performant way?
- Get the number of posts from the current page results
- WordPress Custom Query to show posts from last x years
- Query Custom Meta Value with Increment
- Get posts by meta data OR title
- Meta Query with date and time on the same Day before given time
- Retrieving 3 latest post from each of 5 different custom post types
- get_posts() seemingly ignoring post_type
- How to query ‘posts_per_page’ to display a different blog posts index template?
- How to find out what “Blog pages show at most” is set to [duplicate]
- 2 loops on page – one with orderby rand second orderby date
- How do you Query posts with nothing in common?
- Get posts for last working week in WP_Query
- Query posts by specific word on title
- Five posts from a category in footer
- Multiple loops without repeating content
- WP_Query condition affects posts_per_page count
- add active class based on permalink and url
- Some doubts about how the main query and the custom query works in this custom theme?
- Conflict with get_posts and the_content
- Reset WordPress Post Query to default
- How do I rewrite this loop as a new WP_Query style-loop?
- Include current post into loop
- Best choice for multiple loop in page?
- Get all posts which was posted on X Days WordPress
- How to provide meta_key array to wp_query?
- Use WP_Query or query_posts() or get_posts() for optimizing a site?
- How to create custom query by keyword in post title?
- How to make posts unqueryable/unpublish posts where ACF relationship field is an unpublished post? [closed]
- Conditional operator OR not working with custom fields
- complex get_posts() query to select child pages
- Get posts that do not have the same tags as current
- Should I reset $wp_query?
- Posts query according to meta box date
- How to access $wp_query object from array of posts given by get_posts?
- Function using get_posts() with tax_query not working when called from functions.php
- 2 queries with counters
- Paginate pages with dynamic query
- Performance concerns: index.php vs taxonomy-$taxonomy.php
- Determine if ID is page or post and query the ID
- How to query for a page, get data, then query for child pages of that page
- Custom template for password protected page
- Facing problem with tax_query results
- Populate select list with meta values from all posts of a Custom Post Type
- Duplice post with standard WP loop – fixed by using query_posts() instead
- How do I stop the same post showing multiple times in a archive?
- Related posts queries
- Custom query for custom post type not getting correct post ID
- Problem with my loops
- WordPress For Loop Prints Unwanted Extra Paragraph Element
- How to order posts, that have already been filtered by custom taxonomy, by their category names?
- How to add in WP_Query to every 3 posts displayed? [duplicate]
- query_posts() doesn’t seem to be called in my page
- Some doubts about how the main query and the custom query works in this custom theme?
- Create a hierarchical loop at predefined markup requirements
- Both WP_Query and get_posts returning 1 post
- When should you use WP_Query vs query_posts() vs get_posts()?
- Converting an existing query_posts to WP_Query
- Multiple loop for “featured” items returns wrong posts
- How do I correctly query posts from a post ID?
- tax_query not working properly with get_posts
- Show number of posts AND number on current page (cannot make it work)
- Too slow when using both ‘tax_query’ and ‘meta_query’ both in WP_Query
- Use of caller_ get_ posts
- In loop: posts have thumbnail AND other variables
- Add inline HTML to posts published within last 24hrs
- how to display active, upcoming and past event with featured listing with pagination
- WP_Query, tax_query and term_meta: How to?
- Custom category search box for WordPress
- Refine search results using WP_Query
- How to pass many ids in post__in?
- How to show subcategories using loop?
- Sub-loop / nested loops Best Practices
- Query with a meta value inside a given range
- How do I run through a WordPress loop called from a filter function?
- How do I get the title of a category in a custom loop?
- Check if loop has any categories?
- WordPress query with items from more than one selfdefined taxonomy as `term` argument
- Get all fields inlcuding “ACF” (Advanced Custom Fields) columns in wp_query
- Change query from cat id to slug or name?
- Custom WP_Query id
- posts archive page – closing WP_Query loop correctly [closed]
- AJAX Breaking Offset Argument In WP Query
- Continue or break the while loop
- Why doesn’t my WP Meta Query return any results?
- How to make the ‘request’ filter work?
- how to get custom attachment url?
- WP_Query & Duplicate entries
- Carousel Loop only duplicating
- How to show featured post first, then separate loop for other posts
- posts_per_page – Repeats only first posts ‘post__in’ array
- Pagination only showed when no category is set in wp_query