I will be writing Posts about each of Product's Product Categories (product_cat on products) and I am choosing to group (associate) Posts by the product_cat hierarchical 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' );
}
Much like Category archives, I happen to be using woocommerce which by default lets users browse Product Archives 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,
product_cat
below WooCommerce main content, right ?