Shortcodes inside SEO Field

#4641
  • Resolved Viralalert
    Rank Math free

    Hi, I would like to ask if there’s a way to insert shortcodes in the SEO field title and description. If there’s none, can you make a remedy for this?

    Thank you.

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

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.

    I am afraid that Rank Math does not accept shortcodes on the title or description fields. You can however workaround this by adding some PHP code to your current theme to run the title and description through the do_shortcode() function on specific pages that you want to use the shortcodes.
    You will need to make use of the following filters to achieve this:

    add_filter( 'rank_math/frontend/title', function( $title ) {
    	return $title;
    });
    add_filter( 'rank_math/frontend/description', function( $description ) {
    	return $description;
    });

    Here is an example of how you could use the first filter to execute a shortcode on the meta title field:

    add_filter( 'rank_math/frontend/title', function( $title ) {
            //create some conditional logic here to execute the below for only certain pages/posts
    	$title = do_shortcode($title);
    	return $title;
    });

    I hope this info helps. Thank you.

    ​​​​​​​

    Wow! I love it. It’s working now. Thank you so much. I’m very very happy now. You save my time and day looking for this for plugin.

    However, the SEO description field is not working if I put shortcodes in it.

    Is there a way to do this?

    Also, I want to put shortcodes in the unique URL of the page which display below the post title in search results. For example domain.com/market/[shortcode]/[shortcode]

    Also, I’d like to add if I can use shortcodes in the focus keyword. Thank you so much.

    To sum it up,

    these are the fields I want to use shortcodes of.
    1. Seo description field
    2. unique URL of the page field
    3. focus keyword field

    • This reply was modified 4 years, 11 months ago by Viralalert.
    • This reply was modified 4 years, 11 months ago by Viralalert.
    Todd
    Rank Math free

    Hi,

    Sorry but there is no option to insert the shortcode inside the URL or the focus keyword field.

    We already gave you the code for meta description. Is that not working for you?

    Thank you so much. Yes, it’s working for the description.

    Todd
    Rank Math free

    Hi,

    I am glad.

    If you need help with anything else, please do not hesitate to ask.

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

The ticket ‘Shortcodes inside SEO Field’ is closed to new replies.