How to Display RankMath meta description in the post header

#391309
  • Resolved HarsH SHaH
    Rank Math free

    Can someone guide me to create a shortcode to display RankMath meta description in the post header?

    Here is one method created for AIO SEO plugin.

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

    Thank you for contacting Rank Math support and bringing your concern to our attention.

    I created a custom shortcode for that. Please refer to this code and insert it into your theme’s functions.php file:

    add_shortcode('rm_meta_description', 'rm_shortcode_meta_description');
    function rm_shortcode_meta_description(){
        global $post;
        return RankMath\Post::get_meta( 'description', $post->ID );
    }

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    Thank you so much. It worked very well.

    I have one more doubt, I am using the Generatepress theme. I want to add this shortcode as a hook just before my featured image. Can you help in that case?

    Here is one post link – [moved to sensitive data section]

    Hello,

    It would depend on how the template is created. You can make use of WordPress’s the_content and append or prepend the shortcode you have created. Please refer to this guide: https://developer.wordpress.org/reference/hooks/the_content/

    If the shortcode is needed to be added inside the content, you would need to apply it directly to the template instead. Unfortunately, this is now out of our scope of support. I would suggest checking this one with your theme author as they may be able to help you with that.

    Looking forward to helping you.

    I got it.

    Thanks for the support.

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me 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 do 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.

    Eugen
    Rank Math free

    Hi, I now how get title from post – RankMath\Post::get_meta( ‘title’, $post->ID )

    But how about custom tax? I have custom tax “category-event” https://i.imgur.com/mSeNJmE.png

    Eugen
    Rank Math free

    RankMath\Paper\Paper::get()->get_title();

    resolved

    Hello @eugen-5773,

    Thank you for reaching out to us and we are glad that you are able to resolve your issue.

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

You must be logged in to reply to this ticket.