custom taxonomy names for post meta title with toolset using RankMath

#332692
  • Resolved Graeme Harris
    Rank Math free

    Hi there,

    RankMath so far is an awesome plugin and it’s working great for me.

    Now I have a particular issue where I am using another plugin called Toolset to create custom post types and custom taxonomies within my WordPress website.

    So far this is going very well.

    The trouble I am now running in to, is trying to create a good meta title and meta description for my custom WordPress posts.

    There are hundreds of these custom posts, so what I would like to do is to use the dynamic generation of meta titles and descriptions that Rank Math allows.

    The specific hurdle I am encountering, is that it doesn’t seem Rank Math recognizes the custom taxonomies that I’ve created, so I could use the %category% but this doesn’t give me anything because my posts are in a custom taxonomy, not a regular WordPress category.

    I tried this terminology, %customterm(taxonomy-name)%, which I found here,

    https://rankmath.com/kb/variables-in-seo-title-description/#num-32-custom-term-description

    But this also doesn’t seem to work, just resulting in a Meta Title which says “Custom Term”.

    Am I missing something?

    Or can you please point me in the right direction?

    Thank you!

    G

Viewing 11 replies - 1 through 11 (of 11 total)
  • Hello,

    Thanks for contacting us and sorry for any inconvenience that might have been caused due to that.

    The %customterm(taxonomy-name)% variable will show the Custom Term as output in the preview but will apply the correct taxonomy in the frontend. You can confirm that by checking the source of the page in the frontend or using a tool like https://heymeta.com/

    Let us know how that goes. Looking forward to helping you.

    Hey Jaideep,

    thanks for the reply and clarification.

    I tried this and the front end is just blank where I’ve inserted the %customterm(taxonomy-name)%

    To clarify in case this makes a difference.. I’m trying to use this for one, of a few, different custom taxonomies for my custom posts.

    I’m using the taxonomy to create a couple of archive pages for these posts. Some of them will be classified into both archives.

    Is there any other way to display the taxonomies they belong to in the meta title?

    Or maybe something else I am doing wrong?

    Thanks again for the help!
    G

    Prabhat
    Rank Math agency

    Hello,

    We might need to investigate this by having a closer look at the website.

    Could you please create a screencast of the process you’ve done so far so that we can get a head start? You can use a tool like loom.com to create and share the screencast’s link.

    Please edit the first post on this ticket and include your WordPress & FTP logins in the designated Sensitive Data section.

    Please do take a complete backup of your website before sharing the information with us.
    Sensitive Data Section

    It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:

    https://wordpress.org/plugins/temporary-login-without-password/

    You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):

    https://wordpress.org/plugins/wp-security-audit-log/

    We really look forward to helping you.

    Thanks Prabhat.

    I discovered the issue with a little more tinkering, but still have one more question.

    First I will describe the solution to my issue in case anyone else comes across this problem.

    I’ll mention the fact that I know very little of coding and web development, so maybe this is something that many others wouldn’t have trouble with but:

    When I created my custom taxonomy, I gave it one name, but a different URL slug, for SEO purposes.

    When I was trying to use the %customterm(taxonomy-name)% function, I was putting in the name of the taxonomy, uppercase, lower case, everything, until I realized, I actually need to enter in the different URL slug that I had created the taxonomy with.

    Then it immediately started working.

    Now what I need help with is, my custom taxonomy includes a couple different, soon to be more, tags within the custom taxonomy.

    For some custom posts, more than one of the custom taxonomy tags applies, but when I use %customterm(taxonomy-name)%, only one of the custom taxonomy tags show up.

    I’ve tried the code for when you have multiple categories, ie. (limit = 2 & etc). But this didn’t appear to work.

    Is there a way to display more than one custom taxonomy term with the %customterm(taxonomy-name)% function?

    Thanks again

    Azib Yaqoob
    Rank Math business

    Hello,

    You can use the taxonomy name but not within the same variable. However, you can include the variable as many times as you want.

    We hope that answers your question.

    Please don’t hesitate to contact us again if you need further assistance.

    Thank you

    Hey Azib,

    thanks for the reply.

    Ok I understand that you can include the custom taxonomy variable as many times as you like, in fact I’m already using in multiple times within my meta descriptions.

    The thing is that, many of my custom posts, apply to 2 categories within the same taxonomy.

    Not my case but for an example, if I have a restaurant taxonomy, and then a few sub categories, and one location has the category for Mexican food, and Taco Restaurant, then when I use the custom taxonomy variable for restaurants, which sub category is outputted?

    In my case I have some locations which are categorized in 2 or 3 sub categories, and the custom taxonomy variable only outputs one of the sub categories in the meta titles and descriptions.

    Does this have anything to do with Archive pages created for the sub categories?

    Is there any way to output both?

    I tried using %customterm(taxonomy-name/sub-category-1)%, %customterm(taxonomy-name/sub-category-2)% ; but this just results in nothing being outputted.

    Thanks again for the help!
    G

    Azib Yaqoob
    Rank Math business

    Hello,

    Apologies for the late response.

    You will get the output of the first category name based on alphabetical order. The example you used in the question, if you use this variable then Rank Math will output the Mexican Food category name on the front-end.

    We hope that answers your question. Looking forward to helping you. Thank you.

    ​​​​​​​

    Thanks Azib,

    this makes sense from what I am seeing in my meta titles and descriptions.

    So, now,

    How do I output BOTH of the category names, can I use a command to output ALL categories somehow?

    Thanks!

    Prabhat
    Rank Math agency

    Hello,

    To fetch all the categories of the taxonomy, you can create a custom variable.

    Please add the below code to the website:

    add_action( 'rank_math/vars/register_extra_replacements', function(){
        rank_math_register_var_replacement(
            'get_all_categories',
            [
                'name' => esc_html__( 'Gets the categories attached to the current post', 'rank-math' ),
                'description' => esc_html__( 'Gets the categories attached to the current post.', 'rank-math' ),
                'variable' => 'get_all_categories',
                'example' => 'get_all_categories_callback()',
            ],
            'get_all_categories_callback'
        );
    });
    function get_all_categories_callback() {
        global $post;
        $description = wp_get_post_terms( $post->ID, 'test_cpt_taxonomy' );
        
        foreach ($description  as $term  ) { 
            $cat_name .= $term->name . " ";
        }
        return $cat_name;
    }

    Please replace test_cpt_taxonomy in the above code with the taxonomy slug on your website.

    After adding the above code, you can use the variable %get_all_categories% and see if it gives you the desired output.

    You can follow this guide to add the code:
    https://rankmath.com/kb/wordpress-hooks-actions-filters/

    You may try the code in a staging website first and if everything seems fine, use it in the live website.

    Let us know how that goes.

    Thank you.

    Thank you for the code Prabhat this is much appreciated ! 🙂

    Azib Yaqoob
    Rank Math business

    Hello,

    Glad that helped.

    Please feel free to reach out to us again in case you need any other assistance.

    We are here to help.

    Thank you.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 11 replies - 1 through 11 (of 11 total)

The ticket ‘custom taxonomy names for post meta title with toolset using RankMath’ is closed to new replies.