twitter tag override

#659415
  • Resolved Anonymous
    Rank Math free

    I’m trying to override the twitter:data1 which corresponds to the “written by” label, I’d like to hardcode a User instead of using the real user.

    I’ve already managed to override some but I don’t know how to do it for that meta tag.

    
    add_filter('rank_math/json_ld', function ($data, $jsonld) {
        $data['ProfilePage']['name']             = 'SOME USER';
        $data['ProfilePage']['image']['caption'] = 'SOME USER';
    
        unset($data['WebSite']['potentialAction']);
    
        return $data;
    }, 99, 2);
    
Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello,

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

    You can use the following filter on your website to change the content of twitter:data1 meta tag:

    add_filter( "rank_math/opengraph/slack/twitter_data1", function( $content ) {
    	$content = "Your author name here";
    	return $content;
    });
    

    Hereโ€™s how you can add filter/hook to your WordPress site: https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Hope that helps and please don’t hesitate to let us know if you have any other questions.
    ย 
    Thank you.

    Anonymous
    Rank Math free

    thanks for your reply ๐Ÿ™‚ will try it out.

    I’m adding filters to my own functions.php ๐Ÿ™‚

    Hello,

    We recommend the code in the rankmath.php file or your child theme’s function.php file instead. This way, you do not lose the custom code when you update your theme.

    In any case, please let us know how it goes. If you have any further questions, please do let us know.

    Regards,

    Anonymous
    Rank Math free

    Hi,

    it’s my own child theme so no worry about losing it on update ๐Ÿ™‚ besides it’s versioned in GH as well.
    or is it still recommended to use a rankmath.php in my child theme?

    Regards

    Hello,

    No, your child theme’s function.php file is totally fine. Let us know if you need help with anything else.

    Regards,

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

The ticket ‘twitter tag override’ is closed to new replies.