Since there is no documentation about this, I was wondering in what way it is possible to get filtered Yoast WP SEO data (so not unfiltered _yoast_wpseo
metadata) by given post ID.
Ideally, I would like to get the exact representation of the HTML output by the Yoast plugin, or a full set of data in a JSON object. Ideas?
2
Answers
Untested idea: most of it runs on
wpseo_head
(hooked intowp_head
). Turn on output buffering, make sure your postdata is setup up, and execute it.Use
get_post_meta($postId, '_yoast_wpseo_focuskw')
andget_post_meta($postId, '_yoast_wpseo_metadesc')
I found this question trying to get yoast data from a particular post (by ID) and came to this solution:
Made a function that recieves the post id