I was missing the condition for the array inside the tax_query array. It is important to have it regardless if you have one or more conditions.
$term_search = get_queried_object()->slug;
// WP_Query arguments
$args = array(
'p' => 'product',
'post_type' => array( 'product' ),
'order' => 'ASC',
'post_per_page' => 20,
'tax_query' => array(array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => $term_search, // (the name of what you want to filter by (latest or whatever))
'include_children' => true,
'operator' => 'IN'
)),
);
Related Posts:
- How to Display Custom Post Type’s Gallery (images ) in Through WP_Query
- Paging on a future post loop?
- Finding posts containing matching array elements in a meta field usign WP_Query
- rewrite_rules problem
- Woocommerce Custom Checkout
- Extending theme PHP class in plugin
- Strange issue saving custom field data for a WooCommerce order
- How to access noticeOperations from withNotices
- How to hook a custom user function to a wordpress core ajax action?
- PHP – Extend WordPress Woocommerce Revenue Analytics with custom field
- Woocommerce – Convert Delivery method into a custom field
- Elementor custom Query with ACF fields to show matching woocommerce products custom fields
- WP Gutenberg Blocks – How to limit first/root blocks
- How to get boolean value from register_meta properly?
- “import declarations may only appear at top level of a module” when importing WooCommerce API node module
- Woocommerce extend tax report with custom column
- what is the difference between these phares?
- How can we display product price $104 on the cart while the credit card payment method is checked?
- Fetch Children of Grouped Products Inside WooCommerce Product Loop
- Show disclaimer with accept button before redirecting to the payment gateway website
- Form doesnt save to database
- Notice: Trying to get property ‘term_id’ of non-object
- How do I apply a custom discount to individual product total prices depending on their categories on the cart and checkout pages of WooCommerce? [closed]
- In woocommerce cart item we can add custom text but how can i add custom link? [closed]
- Updating Woocommerce Settings API when WordPress Settings API saved and vise versa
- Can’t get woocommerce_get_price_html to work [closed]
- What is the proper method of using global $post?
- How to restrict access to image folder depending on whether product is purchased or not?
- How to extend WooCommerce API to show bookable product availability rules?
- How developed with version control word press site on shared host? [closed]
- How to export post meta with images in wordpress
- Password field is empty when using wp_signon();
- Customize WooCommerce my account dashboard through plugin
- woocommerce_checkout_order_processed hook executing function twice
- How to change title tag at page after loaded post?
- Following WordPress Markup Is mandatory, got awkward resultyby wordpress standard markup?
- Is there a way in which I can compare product id with the order id to display content on front end before placing the order? [closed]
- Woocommerce Composite Products – Add a composite product to cart programmatically via ajax [closed]
- How do I create plugin or theme using MVC pattern?
- How to limit number of number of categories displayed by categories widget
- PowerPress mobile media player
- When is the proper time to minify css and js with git workflow?
- Strange Situation When Try To Retrieve Github Gist Using wp_remote_get
- How to hide or rename “X” and “x-child” references in website source?
- WordPress custom taxonomy check box to dropdown
- How to Get Current Custom Post Type Associated Taxonomy Term
- Plugin templates vs Parent Theme
- Selectively update themes in WordPress multisite
- Widget HTML Display Problem
- How to create a backend for a custom theme?
- wp_nonce_field displaying twice
- Redirect to another page using contact form 7? [closed]
- Warning: include(): https:// wrapper is disabled in the server configuration by allow_url_include=0
- Change WooCommerce Email Header using custom plugin
- Plugin is not generating title tags on any pages or posts
- Is it necessary to do validation again when retrieving data from database?
- How to Control CSS of Admin On Creating only a Specific Custom Post Type
- Can’t change the style of a submit input type? [closed]
- Make a plugin page out of influence of the theme’s style
- Update Data parameter of a wp_localize_script() call
- UWooCommerce – add cart discount programmatically?
- Custom entity search and display
- WP Plugin Running before jQuery
- How to get the post excerpt using post object?
- Template directory in plugin
- Delist entries in the_loop
- get_the_tags with separator control?
- How to only load css for used blocks on frontend
- 400 Bad Request, in wordpress theme development, wp_ajax
- Remove an action by extending class and replacing it
- Woocommerce order empty items array
- Add child pages to submenu automatically
- How to get all product in the woo-commerce? [closed]
- Why in this archive page that call query_posts() function show only the last 10 posts?
- my own SVN for a plugin/theme
- Issue on Setting $icon_url Parameter on WP add_menu_page()
- Why enqueue styles on hook?
- Getting a WordPress Debug Strategy
- unable to wp_enqueue_script(‘suggest’);
- Drawing the line between theme & plugin on large scale bespoke projects
- Apply styles to blockquote element with the WYSIWYG editor
- PHP File_exist() not working – Checking if File Exist in WordPress Theme Directory
- Woocommerce inventory [closed]
- Why would you use esc_attr() on internal functions?
- Invalid hook call on save, not edit when using swiper slider
- Proper way to use useSelect
- Conditional Generation of Image Sizes using add_image_size
- How to add plugin options in wp editor page
- WooCommerce change Tax Class programmatically when Recalculating an existing Order [closed]
- Add function after the_content
- Ajax: Populate with content from a post’s ID not working – duplicating current page html instead
- How to change WooCommerce loop product title HTML output in single product page and archive page
- Can woocommerse be used dynamically for billing from another plugin for payment processing?
- Sending an SMS on new order placed – WooCommerce
- How to find where an object first instantiatiation
- Gutenberg blocks error: Each child in a list should have a unique “key” prop
- Can we use a library under MIT license in a WooCommerce plugin?
- Set _regular_price 0 if empty in woocommerce product
- WooCommerce Endpoints content
- How remove trashed WooCommerce orders from wc_get_orders() result?