Of course it doesn’t work. What examples are using this code?
Let’s take a look at Category Parameters of WP_Query
There are 5 category parameters:
- cat (int) – use category id.
- category_name (string) – use category slug.
- category__and (array) – use category id.
- category__in (array) – use category id.
- category__not_in (array) – use category id.
There is no category
parameter on that list, so your parameter is unknown and WP_Query
ignores it.
So how should it look?
...
$args = array(
'cat' => 172,
'post_type' => 'post',
'posts_per_page' => 10,
'paged' => $paged
);
...
PS. Also… You shouldn’t use the_title()
in HTML attributes – it won’t get escaped properly. So if the title contains quote character, then it will break your HTML code…
Related Posts:
- Query posts only with featured image
- Order by optional meta key?
- get_query_var function not working at all
- get_query_var( ‘paged’ ) not working outside of homepage
- Why is WP_Query not working with category_name?
- ‘Trying to get property of non-object’ when using WP_Query with ‘fields’ => ‘ids’
- Order by Category and Post in WP custom Query
- get custom post type by tag
- Execute a large WP_Query with many “AND” Meta_Queries?
- Using WP_Query To Get Posts Randomly From today
- RSS feed with specific keyword
- Get All IDs Of A Post Type Using WP_Query
- How to know which one is the main query?
- Multiple endpoints in one URL
- WP_Query can’t exclude more than 1 author?
- How to query using a combination of custom_field values?
- How to order posts by custom WP role?
- Show one post per author and limit query to 8 posts
- Get term by custom term meta and taxonomy
- Generate a tabbed submenu — from taxonomy term or submenu item — with sample content
- posts2posts query using connected_items array issue [closed]
- How to show the posts of some category first, and then all other
- Explanation of WP_Query
- Paginated HTML Sitemap
- Meta query field order together with post_date order causes posts without the meta field to be unordered
- Undefined property: WP_Query::$post
- Excluding Sticky Posts from The Loop and from WP_Query() in WordPress?
- How to get posts on a specific date – WP Query
- WP_Query no posts with tax_query
- My Main Query Modification is Messing up my dynamic main – why?
- WP_Query meta_query >= date
- Query different number of posts with different formats in one go
- Extending woocommerce admin product search
- Pagination is broken and I need help fixing it
- need to exclude APP_TAX_STORE => $term->slug
- Search for multiple tags?
- paging in WP_Query on static page
- Query by multiple meta elements not seeming to work – wordpress is timing out
- Cluster WooCommerce products in each Category Archive by Tags assigned to products
- How can I use $wp_query->tax_query as tax_query parameter for a new WP_Query instatiation?
- Query with search and subscribers only output
- Post loop for all taxonomy terms
- next_post_link / previous_post_link not working with WP_Query
- Customy WP Query Args are convertet in SQL result
- Include post content of linked posts in search
- Query_posts works when appending via AJAX call wp_query doesn’t?
- search serialised meta_value for date value?
- How to make posts unqueryable/unpublish posts where ACF relationship field is an unpublished post? [closed]
- wp_trim_words strips dashicons
- Save (and exclude) posts from loop to use in another loop on page
- Get all posts with empty meta_value
- Count identical post titles
- Storing an array of objects related to each user
- Query by date from custom field
- pass parameters through variable to WP_QUERY
- What is wrong with my WP_Query Arguments?
- Can’t order the query result as given posts id’s array
- Trouble Making WP_Query paged
- Sort posts using multiple custom fields and menu_order in single query?
- Generate custom output on URL with directory
- prevent get_comments() from returning comments not in comment__in
- WP Query should show No Posts when tax_query $args taxonomies don’t have associated posts
- How to make WPQuery custom post type work in Twig / Timber
- Display posts from multiple value in meta separated by comma
- WooCommerce. How To Exclude Subcategory Products From Category Listing Page
- IF ( ! $loop->have_posts() ) condition doesn’t work – WP_Query
- get_posts return only first result
- How to allow a variable with “/” in wordpress url
- Getting posts by custom field value
- Show one post of each custom taxonomy
- wordpress multiple meta value query is not working
- trying to change from query_post to WP_Query
- Strange results from WP_Query
- update_post_meta performance in a loop woocommerce
- Display posts side by side with custom query
- Is there a way to control both Order By and Order query parameters from one input field
- WordPress For Loop Prints Unwanted Extra Paragraph Element
- return child post if available otherwise parent post
- Custom Order Current Query: By Meta Key and Category
- query all posts published by certain user id
- How to create URL parameters to run custom queries?
- Query custom meta value – post view and date meta
- WP_Query – show posts where meta value and user_email match
- WP_Query causing links to not work
- Query Top Set Custom Taxonomy In Given Timeperiod
- Custom taxonomy and query multi conditions
- Orderby Date and Category
- WP_query issue with no posts
- Pagination for custom query throws 404 errors on last pages [duplicate]
- Order posts by custom column using pre_get_posts
- wp_query in form method of widget breaks customizer
- Featured image not showing on page
- Add filter to Orderby Parameter using Array
- Iterate through ID’s in loop
- Need help setting up a search form for wordpress [duplicate]
- problem in query_vars parameters
- Limit Tags display and ad Drop Down Menu
- Query string form $_GET[‘value’] is not working as meta value in wp_query
- Add banner after the third post [closed]
- Is there another way to retrieve a post_id from post_meta other than a SQL query?