Show template part if part of term
Try this if( has_term(‘pude’, ‘produkttype’) || has_term(‘senge’, ‘produkttype’)) { get_template_part( ‘partials/sections/section’, ‘trustpilot’ ); }
Try this if( has_term(‘pude’, ‘produkttype’) || has_term(‘senge’, ‘produkttype’)) { get_template_part( ‘partials/sections/section’, ‘trustpilot’ ); }
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
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
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
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
One simple way to use different layout for child and parent terms is to check, if the current queried object has parent or not and then include the right template part based on a if statement. For example like this, // in your taxonomy/term template file $current_term = get_queried_object(); // parent property is either 0 … Read more
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
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
You have to re-save the permalinks when you add or change a custom taxonomy, or a custom post type. Go to the permalinks settings page, and re-save, then go back and refresh. Also, you don’t need to specify the slug as instructor if the name is instructor, the rewrite option can be removed or just … Read more
This can be achieved multiple ways. One of them is to filter term link with your desired structure. Following is a function that can convert a term link as per your structure. Ignore the first argument, it is there as we will be using this function as a filter callback. /** * @param string $termlink … Read more