How to use Site Title and not SEO Title in Social share by default?

#32567
  • Resolved Sripad
    Rank Math free

    Hey! I want to use Site title in my social share instead of the SEO title.

    Eg, If a post has ABC as the title with XYZ as the SEO title, the social share automatically picks XYZ. How can I make sure it picks ABC instead?

    • This topic was modified 4 years, 1 month ago by Sripad.
Viewing 15 replies - 1 through 15 (of 15 total)
  • Todd
    Rank Math free

    Hi,

    Thanks for getting in touch with us.

    You cannot make that automatic. If you wish to use something other than your SEO title for sharing on social media, you have to manually change that in the social tab:
    null

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

    Sripad
    Rank Math free

    Hey! Thank you for the quick reply.

    I do use it manually now but for a large scale media house, it won’t be possible. For someone pushing out 10-20 articles a day, this is doable. But for a media company pushing out 10-20 articles an hour, it is highly impossible to change the social title every single time.

    Can we have an option in the settings to pick either one?

    Hi there,

    Thank you for getting back to us.

    You can add the following code to your theme’s functions.php file to adjust the Rank Math behavior to use the post title as the og:title:

    /**
     * Allow developers to change the content of specific social meta tags.
     *
     * The dynamic part of the hook name. $network, is the network slug
     * and $og_property, is the property which we are outputting.
     *
     * @param string $content The content of the property.
     */
    add_filter( "rank_math/opengraph/facebook/og_title", function( $content ) {
    	global $post;
    	if($post){
    		return get_the_title($post->ID);
    	}
    	return $content;
    });
    add_filter( "rank_math/opengraph/twitter/og_title", function( $content ) {
    	global $post;
    	if($post){
    		return get_the_title($post->ID);
    	}
    	return $content;
    });
    

    I hope this info helps. Thank you.

    Sripad
    Rank Math free

    Hey Michael Davis, the change in code has not worked. Do I need to change something in the settings too?

    Todd
    Rank Math free

    Hi,

    There is nothing you need to change.

    I just tested it and it works perfectly fine.

    Have you cleared your browser cache? Which theme are you using?

    If that doesn’t work, we might need to take a closer look at the settings. Please include your WP logins in the designated Sensitive Data section.
    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.

    Sripad
    Rank Math free

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    Hello,

    Thank you for the patience.

    I have just checked your posts and the code is already working as expected as shown below:
    Screenshot

    From the screenshot, you will notice that the highlighted title and og:title are different.

    Could you please share some links or the posts/pages where this is not working so that we can check this further?

    Thank you.

    Sripad
    Rank Math free

    Hey Michael,

    Sorry for the late reply. But, it is still not working on any social title.
    Whatever is the SEO title is reflecting on the social cards as well, not the OG title.

    Michael Davis
    Rank Math pro

    Hello,

    Thank you for contacting Rank Math today.

    If you don’t mind, please share with us a sample link that we can investigate further.

    Looking forward to helping you. Thank you.

    ​​​​​​

    Sripad
    Rank Math free

    Hey Michael,

    Please take up any article published on my website and you’ll be able to investigate.

    Michael Davis
    Rank Math pro

    Hello,

    Thank you for contacting Rank Math today.

    I am not quite sure how you are checking that this is not working since everything seems to be working as expected.

    Here is an example post with the following SEO title:

    Chelsea News: 6 Players Ruled Out Of Liverpool Clash

    This is how this looks when sharing to Facebook:
    Screenshot

    Could you please share some screenshots from your end?

    Looking forward to helping you. Thank you.

    ​​​​​​

    Sripad
    Rank Math free

    I just realized that I didn’t specify it’s an issue with Twitter cards. Extremely sorry for that.

    Todd
    Rank Math free

    Hi,

    Please change the above filter to this:

    add_filter( "rank_math/opengraph/facebook/og_title", function( $content ) {
    	global $post;
    	if($post){
    		return get_the_title($post->ID);
    	}
    	return $content;
    });
    add_filter( "rank_math/opengraph/twitter/twitter_title", function( $content ) {
    	global $post;
    	if($post){
    		return get_the_title($post->ID);
    	}
    	return $content;
    });

    That should do the trick. You can check the results here:
    https://cards-dev.twitter.com/validator

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

    Sripad
    Rank Math free

    IT WORKED! Thanks guys.

    Todd
    Rank Math free

    Hi,

    I am so glad to be of help. We are always here if you need us in the future.

    Hey, if it isn’t too much to ask for – would you mind leaving us a review here?

    https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post

    It only takes a couple of minutes but helps us tremendously.

    It would mean so much to us.

    Thank you.

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

The ticket ‘How to use Site Title and not SEO Title in Social share by default?’ is closed to new replies.