Created
September 16, 2013 08:42
-
-
Save tacoverdo/6578081 to your computer and use it in GitHub Desktop.
How to use wpseo_pre_analysis_post_content in WP SEO by Yoast?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add (custom field) content to the post's content before WP SEO Analysis. | |
* | |
* @param string $content The content of a posts content-field. | |
* | |
* @return string The original content plus the value of the postmeta with meta_key '_yoast_postmeta_example'. | |
*/ | |
function yst_custom_content_analysis( $content ) { | |
global $post; | |
return $content . ' ' . get_post_meta( $post->ID, '_yoast_postmeta_example', true ); | |
} | |
add_filter( 'wpseo_pre_analysis_post_content', 'yst_custom_content_analysis' ); |
Add it to your functions.php file in your theme
Just to say, code like this will no longer work as this hook has been removed by Yoast due to it requiring AJAX and slowing down the plugin. You need to use a js plugin as detailed here.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, Can you please let me know where to add this script?