Get Yoast WP SEO data by post ID

0 votes
In what way, is it possible to get filtered Yoast WP SEO data (so not unfiltered _yoast_wpseo metadata) by given post ID.
It would be great to get the exact representation of the HTML output by the Yoast plugin, or a full set of data in a JSON object. any ideas?
Mar 12, 2022 in Digital Marketing by Kichu
• 19,040 points
878 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes
Most of it runs on wpseo_head (hooked into wp_head). Turn on output buffering, make sure your post data is setup up, and execute it.

ob_start();
do_action("wpseo_head");
$yoast = ob_get_contents();
ob_end_clean();

WP SEO resets the global $wp_query back to its original state, ensuring that the plugin always generates the correct HTML output for the current visited post. So the above code to work manipulate that by setting $wp_query to your own query and setting $wp_query->is_singular = true. You'll also have to reset their singleton: WPSEO_Frontend::$instance = false so it's instantiated.
answered Mar 13, 2022 by narikkadan
• 63,600 points

edited Mar 5

Related Questions In Digital Marketing

0 votes
0 answers

Yoast SEO - Get plugin generated data manually

I wanted to get the Yoast SEO ...READ MORE

Mar 2, 2022 in Digital Marketing by Kichu
• 19,040 points
1,254 views
0 votes
1 answer

Yoast SEO: remove og:description and twitter:description

add_filter("wpseo_opengraph_desc", "remove_yoast_og"); add_filter("wpseo_twitter_description", "remove_yoast_og"); function remove_yoast_og($description) { ...READ MORE

answered Mar 1, 2022 in Digital Marketing by narikkadan
• 63,600 points
867 views
0 votes
1 answer

How to over-ride meta data in Wordpress, using Squirrly SEO

if (is_archive()){ add_filter('sq_title', 'filter_product_wpseo_metadesc'); function filter_product_wpseo_metadesc($wpseo_metadesc){ ...READ MORE

answered Mar 1, 2022 in Digital Marketing by narikkadan
• 63,600 points
975 views
0 votes
0 answers

WP All in one SEO, does it have a database?

I am using wordpress for my website ...READ MORE

Mar 2, 2022 in Digital Marketing by Kichu
• 19,040 points
405 views
0 votes
0 answers

seo toolkit - request is disallowed by a robots.txt rule

I am trying to run the SEO ...READ MORE

Mar 2, 2022 in Digital Marketing by Kichu
• 19,040 points
389 views
0 votes
1 answer

How to remove home page title in Yoast SEO?

Here, you have two possibilities. You can ...READ MORE

answered Mar 4, 2022 in Digital Marketing by narikkadan
• 63,600 points
3,270 views
0 votes
1 answer

How to Access Yoast SEO tags in Wordpress API Callback

use rest api to request for the ...READ MORE

answered Feb 12, 2022 in Others by narikkadan
• 63,600 points
1,964 views
0 votes
1 answer

Yoast SEO (WordPress Plugin) - Get plugin generated data manually

get_post_meta(), use this to get the meta ...READ MORE

answered Feb 11, 2022 in Others by narikkadan
• 63,600 points
1,603 views
0 votes
1 answer

Simple question regarding PHP, Wordpress & Yoast SEO

the way the search engine displays your ...READ MORE

answered Feb 14, 2022 in Others by narikkadan
• 63,600 points
581 views
0 votes
1 answer

how can I change yoast seo generated sitemap file URL?

plugins/wordpress-seo/inc/sitemaps/class-sitemaps-router.php go to this directory and change the ...READ MORE

answered Feb 22, 2022 in Others by narikkadan
• 63,600 points
3,791 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP