Adding default variables to SEO Titles and Meta

#313367
  • Resolved Richard Harvan
    Rank Math free

    Hello,

    this is feature request … Just by using your plugin for a few days for my new woocommerce shop I found out you are missing essential variables.

    1 – Long product description – Yes, I found that I can chenge that by custom snippet and adding %woo_full_desc% to the meta … but it is manual for every single post, and also people have to search for that
    2 – I am pissing Parent category/taxonomy/term name …. for example parent category is Cars and child is Diesel … Yes, I know, I can call the child Diesel Cars but it doesnt always work like that especially if you have long category names … also, most important is to use it in attributes … for example you have Attribute name Engine capacity and values 1,8L, 2L, 3L etc. … You dont want your Titles to be only 2L, you want it to be Engine Capacity: 2L … and in this case you will definitely not input values of attributes like Engine Capacity: 2L because it will be looking mess in filtering for example and everywhere else too

    Please add those two …

    Also I am missing one thing that should be done easier … I know that we can all translate your plugin, but there is only one thing I found out important to translate and it is “page 4 of 8” … those are only 2 words that your customers should by able to change in the dashboard, not in files … it would definitely improve the usage of plugin

    Thank you for considering those implementations and fast delivery if possible

    Wish you the best

Viewing 13 replies - 1 through 13 (of 13 total)
  • Prabhat
    Rank Math agency

    Hello,

    1. Assuming you’ve used the code provided by my colleague here to get the long description: https://support.rankmath.com/ticket/woocommerce-product-long-description/?view=all#post-191236

    You can add the %woo_full_desc% variable in Rank Math > Titles & Meta > Products > Single Product Description.

    Once done, you can add the below code to allow Rank Math to prioritize global settings for the meta description of products:

    add_action( 'rank_math/frontend/description', function( $generated ) {
    	if ( ! is_product() ) {
    		return $generated;
    	}
    	global $post;
    	$desc = RankMath\Helper::get_settings( "titles.pt_product_description" );
    	$desc = RankMath\Helper::replace_vars( $desc, $post );
    	return empty( $desc ) ? $generated : $desc;
    });

    Here’s a guide that you can follow to add the code:
    https://rankmath.com/kb/wordpress-hooks-actions-filters/

    2. Could you please create a screencast of this so that we can better understand the situation?

    You can use a tool like loom.com to share the screencast’s link.

    Looking forward to hearing back from you.

    Thank you.

    https://www.loom.com/share/e63d04a1a1bf4531a7f906a3cdd4794b

    maybe this will help … I am trying to add attribute name automatically to SEO titles of attribute value archives

    Prabhat
    Rank Math agency

    Hello,

    Thank you for the screencast.

    To fetch the name of the attribute in the SEO title field, you can add the %title% variable to the attributes.

    You can also add the above variables under Rank Math > Titles & Meta > Product Attribute (or name of the attribute) > Archive Titles. Doing this would automatically add the attribute name in the SEO Title of the new attributes.

    Once done, give Google some time to crawl the website again and see if the title gets updated.

    Hope this helps.

    Thank you.

    https://www.loom.com/share/e63d04a1a1bf4531a7f906a3cdd4794b

    https://www.loom.com/share/468f0c426ead4aa1a42a6f9f450bd4ea

    the second issue in the second link … I am trying automatically to add the parent category name to the title of their childs … I dont want child category to be named “Phunnel korunky” (Phunnel hookah bowls), just Phunnel … but for context in search results, I want people to see on google Phunnel bowls because it makes sense for them … the reason why I dont name my category childs in full name is that sometimes it is so long name that in menus, widgets etc it would be too long to display

    Prabhat
    Rank Math agency

    Hello,

    1. As I mentioned in my previous reply, adding the %title% variable in the global settings (Rank Math > Titles & Meta > Product Attribute > Archive Titles) would work only for new attributes.

    For existing attributes, as their data is already stored, you’ll need to add the %title% variable to them manually by editing the attributes.

    2. Please add this code to your website to register a new variable named %get_parent_category_title% and use this variable in the title field to see if you get the desired output:

    add_action( 'rank_math/vars/register_extra_replacements', function(){
        rank_math_register_var_replacement(
            'get_parent_category_title',
            [
                'name' => esc_html__( 'Title of Parent category', 'rank-math' ),
                'description' => esc_html__( 'Display the title of parent category.', 'rank-math' ),
                'variable' => 'get_parent_category_title',
                'example' => 'get_parent_category_title()',
            ],
            'get_parent_category_title'
        );
    });
    function get_parent_category_title() {
    	$cat = get_queried_object();
    	$parent_cat_id = $cat->parent;		
    	$term = get_term( $parent_cat_id );	
    	
        return $term->name;
    }

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

    Please let us know how that goes.

    Thank you.

    Thank you for helping me, the category works great, you should definitely implement it to core ๐Ÿ™‚ but don’t have to, I will have competitive advantage ๐Ÿ˜€

    For the attribute values … I went manually to the attribute values and added the %title% to them … this is what happened … the %title% returns Attribute VALUE, not Attribute parent NAME

    https://ibb.co/Cz7tDpJ

    Either I am doing something wrong, or you misunderstood me

    And on the frontend there is even no change unfortunately

    https://ibb.co/xLTsbCh

    Prabhat
    Rank Math agency

    Hello,

    Seems like I did misunderstand the requirement.

    Please try adding the below code and use the variable %get_attribute_label% to get the attribute name and see if it gives you the required output:

    add_action( 'rank_math/vars/register_extra_replacements', function(){
        rank_math_register_var_replacement(
            'get_attribute_label',
            [
                'name' => esc_html__( 'Gets the attributes label', 'rank-math' ),
                'description' => esc_html__( 'Display the attributes label.', 'rank-math' ),
                'variable' => 'get_attribute_label',
                'example' => 'get_attribute_label()',
            ],
            'get_attribute_label'
        );
    });
    function get_attribute_label() {
    	$current_attribute_id = get_queried_object()->term_id;
    	$texomomy_name = get_queried_object($current_attribute_id)->taxonomy;
    	$texomomy_label = wc_attribute_label( $texomomy_name );
    	
        return $texomomy_label;
    }

    Please let us know how that goes.

    Thank you.

    You are genius ๐Ÿ™‚ works like intended … should be also integrated to core ๐Ÿ™‚ thank you a lot … this help and support is simply awesome

    Prabhat
    Rank Math agency

    Hello,

    We are super happy that we could address your concern. If you have any other questions in the future, know that we are here to help you.

    If you donโ€™t mind us asking, could you please leave us a review (if you havenโ€™t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

    Prabhat
    Rank Math agency

    Hello,

    Thank you so much for your review. We really appreciate it.

    Please feel free to get in touch if you require any further assistance.

    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 13 replies - 1 through 13 (of 13 total)

The ticket ‘Adding default variables to SEO Titles and Meta’ is closed to new replies.