• In prod_cat archives how to show posts having same/similar prod_cat structure?

    I will be writing posts about each of the product categories and chose to group them by the product.product_cat taxonomy. To do this without duplicating the taxonomy, I registered it in my functions.php like so:

    
    add_action( 'init', 'register_product_cat_taxonomy_for_post_object' );
    function register_product_cat_taxonomy_for_post_object() {
         register_taxonomy_for_object_type( 'product_cat', 'post' ); 
    }
    

    By default with woocommerce, users can browse Products by Product Category. They simply click the provided product_cat breadcumbs and i believe archive-product.php will display a list of products that have a product_cat matching the clicked-on breadcrumb.

    I am having trouble with my next objective. I plan to hook-into the archive-product.php do_action( ‘woocommerce_after_main_content’ ); to inject some custom funtionality, but I am having trouble writing the custom functionality. I am looking for help writing two different query/display codes to show:

    1) posts whose list of product_cat slugs match at minimum the list of product_cat slugs in the breadcrumbs mentioned above. When I say “posts whose…prouduct_cat slugs” refer to the register_product_cat_taxonomy_for_post_object() function above for clarification.

    2) posts whose list of product_cat slugs match exactly the list of product_cat slugs in the breadcrumbs mentioned above. When I say “posts whose…prouduct_cat slugs” refer to the register_product_cat_taxonomy_for_post_object() function above for clarification.

    Ultimately, the goal is for me to write posts, assign posts specific product_cat terms, then figure out #1 and #2 so that users who are breadcrumb-browsing products by product category can also see (via my injection of #1 and #2) posts related to the product category that they are currently breadcrumb-browsing in archive-product.php

    Thank you,

  • The topic ‘In prod_cat archives how to show posts having same/similar prod_cat structure?’ is closed to new replies.