hooks – How to display two different custom taxonomy terms on a WooCommerce single product page

Our WooCommerce products have two custom taxonomies: sizes and colors.

I’m trying to display the custom toxonomy terms for a product on its single product page. I’m using the woocommerce_single_product_summary action hook. I can’t get both taxonomies to display at the same time.

Here’s my code so far:

 * display a woocommerce product's custom taxonomy terms on single product pages

function display_single_product_sizes_after_summary() { 
    global $post;
    $size_terms = get_the_terms( $post->ID , array( 'sizes') );
    // begin creating html markup
    $size_markup = '';
    if(!empty($size_terms)) {
        $size_markup .= "<p>Similar size shades: ";
    // init counter
    $is = 1;
    foreach ( $size_terms as $size_term ) {
        $size_markup .= '<a href="/shades/size/' . $size_term->slug . '">' . $size_term->name . '</a>';
        //  Add comma (except after the last item)
        $size_markup .= ($is < count($size_terms))? ", " : "";
        // Increment counter
        //finish the markup
        if(!empty($size_terms)) {
            $size_markup .= "</p>";
    echo $size_markup;

function display_single_product_colors_after_summary() { 
    global $post;
    $color_terms = get_the_terms( $post->ID , array( 'colors') );
    // begin creating html markup
    $color_markup = '';
    if(!empty($color_terms)) {
        $color_markup .= "<p>Similar color shades: ";
    // init counter
    $ic = 1;
    foreach ( $color_terms as $color_term ) {
        $color_markup .= '<a href="/shades/color/' . $color_term->slug . '">' . $color_term->name . '</a>';
        //  Add comma (except after the last item)
        $color_markup .= ($ic < count($color_terms))? ", " : "";
        // Increment counter
        //finish the markup
        if(!empty($color_terms)) {
            $color_markup .= "</p>";
    echo $color_markup;

function display_single_product_terms_after_summary() {
add_action( 'woocommerce_single_product_summary', 'display_single_product_terms_after_summary', 101, 0 );

This outputs the following:

Similar size shades: Small

Similar color shades:

If I reverse the order of the two sub-functions in display_single_product_traits_after_summary the output changes to:

Similar color shades: Blue

Similar size shades:

I’ve tried to use a reset at the end of each subfunction. I’ve tried:

    echo $size_markup;


    echo $color_markup;

This makes no difference.

I’ve also tried:

    echo $size_markup;


    echo $color_markup;

This breaks the page altogether.

What is my mistake here, and how can I get the terms from both taxonomies to display?

object oriented – Can other behavioral OOP design patterns be expressed in terms of Strategy and Template Method Patterns for behaviour parameterization?

I’m studying OOP design patterns in a solution-oriented way which I mean not concentrating just one pattern but with a comparative analysis like their combined or hybrid usages and equivalents in dynamic languages or in functional languages.

As the GoF grouping name behavioral patterns implies, this patterns are for behavior parameterization by utilizing single method dynamic dispatch in terms of polymorphism that OOP languages provides inherently AFAIK. I assume Strategy pattern as the main form of this mechanism and Template method pattern as its derivation which also keeps common code. Is that reasoning right? Can we approach polymorphism in OOP in this way?

If we think outside of OOP there are higher order functions and lambda functions in dynamic languages and functional languages or mix of them. I think that these languages provides only a few patterns/constructs in contrast to the GoF catalog which I map them to Strategy and Template Method Patterns in essence.

With this perspective, I have analyzed other behavioral patterns and then this question can’t get out of my mind. Even if it looks general but I think I’ve tried to be specific, I’m taking the risk of asking here.

Can we do the same job with Strategy or Template patterns instead of Command, Chain of Responsibility or Decorator(Structural but let's assume in this group) for an example in more or less finer design?

Note: I’m not trying to generalize so for example I know Visitor pattern is out of this scope since it solves the expression problem.

taxonomy terms – Two views with the same path- how to change which one “wins”?

I have two views in Drupal 8.

  1. The standard Taxonomy term (content) view, path: /taxonomy/term/%
  2. My custom view for just one term at path: /term-alias

When I go to my custom term, I see the view for all terms (#1), when I want to force it to #2. How can I do that?

8 – Styling listing page for taxonomy terms

I’m styling a listing page for content marked with a certain content keyword (taxonomy term).
I already have a views-view-unformatted–taxonomy-term–content-keyword.html.twig file to display the fields.
I’m in the process of creating node–view-taxonomy-term.html.twig, but upon early testing, the content.body field is displaying the inline css code.

I want to create a page view, but it requires me to specify a url. I’m trying to make this work for all content marked with content keywords.

sample code from views-view-unformatted–taxonomy-term–content-keyword.html.twig

{% for row in rows %}
    set row_classes = (
  <div{{ row.attributes.addClass(row_classes) }}>
    {{- row.content -}}
{% endfor %}

and then sample code for node–view–taxonomy-term.html.twig

<div class="cell auto">
  <h3><a  href="{{- goto_url -}}">{{ label }} </a></h3>
  <div class="">{{ content.body }}</div>

terms – Updating YOAST metatitle + metadescription within a custom taxonomy?

I was just wondering if there was a way to update the yoast metadescription/title for a custom taxonomy?

I know that posts have:

update_post_meta($post_id, '_yoast_wpseo_metadesc'); 

Which is nice and simple


For taxonomies the closest I could get was:

$term_id = get_queried_object_id();
$meta = get_option( 'wpseo_taxonomy_meta' );
$new_data = $meta;
$new_data('product_type')('198')('wpseo_title') = 'testing now';
update_option('wpseo_taxonomy_meta', $new_data);

Which does update the metadesc for the taxonomy in the backend CMS – however, it needs to then be manually saved afterwards for it to take effect, which isn’t going to work in my situation

Thanks for any help!

customization – Use same slug base for Custom Post Type posts, and multiple taxonomy terms

I have done a lot of digging the past few days, and can come close, but not exactly what I need.
I’m trying to alter a custom taxonomy/CPT permalink structure to all use the same slug base: /resources/.

CPT: 'resources'

TAX1, non-hierarchical: 'type'

TAX2, hierarchical: 'section'

I need the structure to look like this:

/resources/ = static page with blocks WORKS
/resources/$type-term/ = archive for all Resources posts with this term DOESN’T WORK – 404
/resources/$type-term/page/1 = pagination for type-term archive DOESN’T WORK
/resources/$section-term-parent/ = static page with blocks WORKS
/resources/$section-term-parent/$section-term-child/ = archive for all Resources posts with this child term WORKS
/resources/$section-term-parent/$section-term-child/page/2 = pagination for section-child-term archive WORKS
/resources/$post-name = url for all Resources posts DOESN’T WORK – 404

I need to remove the taxonomy names from both taxonomies, and use only the term name. Both taxonomies need to have /resources/ before them in the URL. The single posts need /resources/ before the post slug. It needs to be set at the WP level and not .htaccess because we have a load balancer directing all non-resources traffic to another system. If it’s not in /resources/ it will never hit WP.

I can only get one taxonomy at a time to use the structure, but not both. Whichever taxonomy I declare second is the one that works. I am using %category%/%postname% in my global permalink rules.

Registering content types:

add_action( 'init', 'create_format_taxonomy', 1 );
function create_format_taxonomy() {
    $labels = array(
        'name'                      => _x( 'Formats', 'taxonomy general name', 'mysite' ),

    $args = array(
        'hierarchical'              => true,
        'labels'                    => $labels,
        'show_ui'                   => true,
        'show_admin_column'         => true,
        'update_count_callback'     => '_update_post_term_count',
        'query_var'                 => true,
        'rewrite'                   => array( 'slug' => 'resources', 'with_front' => true ),
        'show_in_rest'              => true,
        'rest_base'                 => 'format',
        'rest_controller_class'     => 'WP_REST_Terms_Controller',

    register_taxonomy( 'format', 'resources', $args );

add_action( 'init', 'create_resources_cpt' );
function create_resources_cpt() {
    $labels = array(
        'name'               => _x( 'Resources', 'Post type general name', 'mysite' ),

    $args = array(
        'labels'             => $labels,
        'public'             => true,
        'publicly_queryable' => true,
        'show_ui'            => true,
        'show_in_menu'       => true,
        'query_var'          => true,
        'rewrite'            => array( 'slug' => 'resources', 'with_front' => false ),
        'capability_type'    => 'post',
        'has_archive'        => false,
        'hierarchical'       => false,
        'menu_position'      => 15,
        'show_in_rest'       => true,
           'supports'        => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments', 'revisions' ),
        'taxonomies'         => array( 'format', 'section' ),

    register_post_type( 'resources', $args );

function create_section_taxonomy() {

    $labels = array(
        'name'                  => _x( 'Sections', 'taxonomy general name', 'mysite' ),

    $args = array(
        'hierarchical'          => true,
        'labels'                => $labels,
        'show_ui'               => true,
        'show_admin_column'     => true,
        'query_var'             => true,
        'rewrite'               => array( 'slug' => 'resources', 'with_front' => false ),
        'show_in_rest'          => true,
        'rest_base'             => 'section',
        'rest_controller_class' => 'WP_REST_Terms_Controller',

    register_taxonomy( 'section', array( 'resources' ), $args );

add_action( 'init', 'create_section_taxonomy', 1 );

I am using single_template and template_redirect hooks for the parent term static pages, this works fine. However the Format link is not working. If I change the order – register Section before Format, then Format works and Section doesn’t. The only way the single post url works is if I change the slug in the CPT definition to something other than resources.

terms – Show content/template for the /tag/ or /taxonomy/ part of the URL in WordPress


I’ve been trying to figure this problem out but can’t quite find an answer.

On my WordPress site, the URL for tags is mysite.com/tag/tag-term. This displays fine using the tag.php template. However, If I just go to mysite.com/tag/ I get a 404 error. It is the same for custom taxonomies I have. For example, I have custom taxonomy of developer so if I goto mysite.com/developer/term it loads content under that term using taxonomy-developer.php template. But going to mysite.com/developer/ returns a 404.

Is there a template I can use, or some other method to get WordPress to display a list of terms if someone goes to the /tag/ or /taxonomy/ part of the URL?


How to hide terms in edit.php

I would like to know the hook to overwrite the display of terms list for taxonomy in post edition page.
My goal is to hide some terms for a specific taxonomy that I cannot remove (generated by theme each time I try to remove it ) in wp-admin/edit.php?post_type=foo.
I´m looking for this hook without success.

What is the bounce rate in terms of SEO? – SEO Help (General Chat)

Hi Friend,
A website’s bounce rate is perhaps one of the most undervalued metrics of a successful SEO campaign. In general, a bounce rate is the amount of visitors to any given website who navigate off of the site after viewing only one page, typically expressed as a percentage.

regions – Hyper Tetrahedron in terms of inequalities

The command Tetrahedron[] seems to work fine for the 3-d case. But how can we get hyper-tetrahedron for 4-d case in terms of inequality? Take for example the points:


The hyper-tetrahedron formed by these 5 points can be found out manually to be x1>0 && x2>0 && x3>0 && x4>0 && x1+x2+x3+x4<1. But how can we get it easily for any set of 5 points in 4-d using Mathematica?