Skip to content

Instantly share code, notes, and snippets.

@tacoverdo
Created September 16, 2013 08:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tacoverdo/6578081 to your computer and use it in GitHub Desktop.
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?
<?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' );
@feyazbeck
Copy link

Hello, Can you please let me know where to add this script?

@richardhedges
Copy link

Add it to your functions.php file in your theme

@jason-murray
Copy link

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