• Resolved andybds

    (@andybds)


    how can i restrict the wc_get_template_part function to only return products with a particular category assigned?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter andybds

    (@andybds)

    can get_terms include a restriction to particular postmeta?

    Plugin Support Shameem R. a11n

    (@shameemreza)

    Hello @andybds

    how can i restrict the wc_get_template_part function to only return products with a particular category assigned?

    To restrict the wc_get_template_part function to only return products from a specific category, you can use a conditional statement with the has_term function in your theme’s WooCommerce template files. Here I found some resources that might help you:

    Alternatively, you can also consider using a shortcode like [products limit="8" columns="4" category="hoodies, tshirts" cat_operator="AND"] and hiding the default shop loop with a snippet like this.

    can get_terms include a restriction to particular postmeta?

    The get_terms function is used to retrieve the terms in a taxonomy or taxonomies. It doesn’t include a restriction to particular postmeta directly. However, you can use WP_Query or get_posts with a meta_query to get posts with specific postmeta, then use wp_get_post_terms to get the terms for those posts.

    Please note that we don’t provide support for coding or customization as per our support policy. Still, if you need help, we recommend asking development questions on the #developers channel of the WooCommerce Community Slack. Many of our developers hang out there and will be able to offer insights into your question.

    I wish I could help more, but hopefully, this gets you going in the right direction to get the job done.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Filter taxonomy list’ is closed to new replies.