Meta Title. Category + attribute

#581751
  • Resolved Denis
    Rank Math free

    Good afternoon.

    My meta title is not displayed correctly.

    I put this code in the site:


    add_filter( 'rank_math/frontend/title', function( $title ) {
    if( is_product_category() ) {
    $filter_brand = $_GET['filter_brand'];
    $space = ' ';

    if ( isset($filter_brand) ) {
    $title = ucfirst($filter_brand) . $space . $title;
    }
    }
    return $title;
    });

    Here I apply the brand filter and the code for some reason takes the name of the brand from the URL. As it shows it in the meta description through the “-“.

    Example:
    https://soundsmag.com/product-category/drums-and-percussion/percussion/?filter_brand=bare-knuckle

    I need that would be taken from the title of the brand name with correct case and with spaces.

    Can you tell me how to do it right?

    Regards Denis.

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

    Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for any inconvenience this issue may have caused you.

    I’ve checked the page, and its title is already set this one with space

    Bare-knuckle Percussion ● New Arrivals May 2023 | SoundsMag™
    

    Could you please share the expected title you wanted to achieve so we can check further?

    Looking forward to helping you.

    Thank you.

    Denis
    Rank Math free

    Brobel I meant in the brand.

    Also, he writes only the first letter of the capital brand, although there are those that are written with a small letter.

    Examples:
    Bare Knuckle Percussion ● New Arrivals May 2023 | SoundsMag™

    That the brand would be spelled exactly the same as on the site. With the correct case and spaces.

    Regards Denis.

    Hello,

    Thank you for clarifying.

    In this case, please update this line in the filter you shared:
    $title = ucfirst($filter_brand) . $space . $title;

    To this one:

    $title = ucwords(str_replace('-', ' ', $filter_brand)) . $space . $title;
    

    Once done, check again if the title is removing the hyphen and use uppercase words.

    Let us know how this goes.

    Thank you.

    Denis
    Rank Math free

    Thank you!

    It’s working great now.

    Here’s another question. There are brands that are written like this:

    ATV (But spelled like this: Atv)
    1stClassRock (But spelled like this: 1stclassrock)
    Hands on Drums (But spelled like this: Hands On Drums)

    How do I make the case be exactly the same as in the name of the brand?

    Regards Denis.

    Hello,

    Unfortunately, this can’t be easily achieved by the code as in cases like this, there’s no way a program can determine (unless the code checks for a list of vocabulary) if the text from the URL parameter is for an acronym or meant for camel casing.

    This type of customization needs extensive coding to achieve the desired output which is now outside our scope of support.

    Looking forward to helping you.

    Denis
    Rank Math free

    Thank you so much for your support!

    Hello,

    We are glad that we could address your concern.

    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.

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

You must be logged in to reply to this ticket.