Hello,
If you want to ensure that the meta tags are placed at the beginning of the tag in your WordPress theme, you can utilize a custom hook that fires before the `wp_head` hook. By printing the meta tags in this custom hook and removing them from the default one, you can control their placement within the section.
To achieve this with Rank Math, you can use custom filters to modify the Open Graph tags. For example, if you wish to customize the Open Graph title tag, you can use a filter like this:
add_filter('rank_math/opengraph/facebook/og_title', function ($content) {
// Your custom logic to set the Open Graph title here
return $content;
});
Similarly, if you need to remove a specific Open Graph tag added by Rank Math, such as removing the post category from the article:section tag, you can use a filter like this:
add_filter('rank_math/opengraph/facebook/article_section', function ($content) {
// Your logic to remove the specific Open Graph tag here
return $content;
});
By using these custom filters, you can control the output of Open Graph meta tags and ensure they are placed where you want them within the “ section of your theme.
If you need further assistance or have any other questions, feel free to ask. Thank you for reaching out!
Sources:
Open Graph Meta Tags » Rank Math
How to Make Your Theme Rank Math Compatible » Rank Math
I need further assistance in regards where to add this code.
Hello,
Thank you for contacting support.
You cannot change the placement of the meta tags from our plugin and it’s not possible to change the way they get fired on the pages.
We already use the wp_head hook in our plugin to handle this so it’s not possible to change this to any other hook.
Don’t hesitate to get in touch if you have any other questions.
Thank you for your reply.
Actually, I am working on thumbnail preview sharing via whatsapp, I got succeed within same theme using Yoast Seo plugin, whatsapp fetch the preview image within first 300kb. I just need move og tags before any scripts on pages runs, (SS Attached). That will resolve my issue.
Hello,
Unfortunately, it is not possible to change the placement of the meta tags. The only way you can resolve this issue is by moving your inline CSS to a file. If you’re not sure how to do that, you can get in touch with your theme support.
Hope that helps and please don’t hesitate to let us know if you have any other questions.
Thank you.
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.