List just subcategory and products of active category page in Woocommerce

The code below works for me in archive-product.php not sure if it may also work in taxonomy-product_cat.php EDIT I’ve added some lines of code to exclude posts previously outputted, since a post can belong to several categories and that’s why you can find always the same posts if(is_a(get_queried_object(),’WP_term’)){ $subs=get_terms(‘product_cat’,array(‘parent’=>get_queried_object()->term_id)); //var_dump($subs); $to_excude=[]; foreach($subs as $sub){ $args … Read more

I receive taxonomy id

there is a mistake in fetching the product attribute name. first of all, we have to get all options ids & attribute names than we have to fetch attribute name by its id & attribute slug. please check below updated code snippet and let me know if this is worked for you or not.if not … Read more

Modify output of wp_dropdown_categories to add term IDs to each option

get_terms ended up bring a more customizable solution which is working for my needs. I was able to easily add the term IDs to each option as needed. Hope this helps someone else. <div class=”location-cats-dropdown”> <form id=”location-category-select” class=”location-category-select” method=”get”> <?php $loc_cats = get_terms( array( ‘taxonomy’ => ‘location_category’, ‘hide_empty’ => true, ‘orderby’ => ‘menu_order’, ‘order’ => … Read more

Echo text using is_tag

That’s not what is_tag does: Determines whether the query is for an existing tag archive page. https://developer.wordpress.org/reference/functions/is_tag/ is_tag and other functions such as is_search etc don’t tell you anything about a post, they tell you if you’re on a search archive, or a tag archive, etc So is_tag is true on example.com/tag/example but would be … Read more

Add class to website based on post taxonomy

You can use the body_class filter in WordPress to add the Taxonomy Terms of a Custom Taxonomy as CSS classes to a post. The CSS class appears in the body element and is only used if the post has been assigned to the taxonomy. The code goes in your functions.php file. add_filter( ‘body_class’, ‘themeprefix_add_taxonomy_class’ ); … Read more

WP Job Manager plugin – Listing only the twelve job categories on frontpage order by jobs they have

Edited: This is a much simpler version of what you are looking to do. You don’t need WP_Query(). You can use a foreach loop and an iterator: <?php echo ‘<ul class=”job-category-list”>’; // Get the terms and order them by count in descending order. $terms = get_terms( [ ‘taxonomy’ => ‘job_listing_category’, ‘orderby’ => ‘count’, ‘order’ => … Read more