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)
- When to use WP_query(), query_posts() and pre_get_posts
- Display all attached image of every post of custom post type and link to original post
- Get posts with no tags?
- Show single posts date, in a page of posts
- get_posts query matches too many results
- wp-query, pull children of parent page
- Max Posts and Memory Limit
- relation OR instead of AND – Filtered term ID’s in loop
- Writing less unnecessary code with WordPress
- Does query_posts have an effect on get_the_category?
- Second loop pagination changes URL, not content
- specific post is not excluded from the loop
- How to change the default post type over the loop?
- I am officially missing something about transient posts
- Search for pages with permalink
- Query Not working as expected
- Why doesn’t my WP Meta Query return any results?
- Multiple Query_Posts
- Compare “Main” post ID to ID inside wp_query loop
- Offset WP_Query by negative 1
- WP_Query orderby random do not repeat infinite scroll – one loop
- WP_Query loop doen’t work with my custom taxonomy
- Advise on Templates for Custom Queries
- filter posts by meta key with pagination
- Trouble Making WP_Query paged
- Display 3 posts with different HTML markup using a loop
- Search.php – return number of results but cannot loop through
- How do I get the content of a custom instance of WP_Query?
- Creating ‘posts page’ loop based on the page itself
- Why does apply_filters behave different inside and outside a loop?