Viewing 3 reply threads
  • Author
    Posts
    • #3841
      dre711
      Member

      Posted this question to Twitter yesterday and got a slight response, but will all my fields get read by Yoast if run them through the wpseo_pre_analysis_post_content filter?

      Can I have someone show an actual example of all fields being put through that filter?

      Thanks.

    • #3842
      Steve
      Keymaster

      @dre711– Welcome to the Piklist community!

      Since Piklist does everything the WordPress way, any information you can find on the Yoast wpseo_pre_analysis_post_content filter would work.

      Here’s what I found. Add this to your theme’s functions.php file or your main plugin file:

      function my_custom_content_analysis($content)
      {
      	global $post;
      
      	return $content . ' ' . get_post_meta($post->ID, 'PIKLIST-FIELD-NAME', true);
      }
      
      add_filter('wpseo_pre_analysis_post_content', 'my_custom_content_analysis');
      

      The PIKLIST-FIELD-NAME is the field parameter when in your field array.

      This code will only work with text, textarea and editor field. If you want to do something fancier, you may have to pull the post_meta and loop through the data.

      Let us know if you need any more help.

    • #3844
      dre711
      Member

      So are you saying for all my different fields created throughout a site to get read by Yoast, I would have to create a new function for each ‘PIKLIST-FIELD-NAME’? There’s not a global catch all my fields?

      Thanks!

    • #3846
      Steve
      Keymaster

      @dre711– This is really a question for Yoast, on the best way to add all your custom fields (Piklist or others) to his plugin.

      However, I found this post that might help >.

      Essentially, you can use the WordPress function get_post_custom to pull all your custom fields, and then loop through theme and add them to the $content parameter.

      Does that make sense?

Viewing 3 reply threads
  • The topic ‘All Fields Read by Yoast SEO?’ is closed to new replies.