• Resolved jordanmc

    (@jordanmc)


    I want to get Yoast values in the WordPress save_post hook, in my child theme’s functions.php.

    How can I grab Yoast values from a post?

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @jordanmc,

    Thank you for reaching out.

    Would you mind elaborating a bit on what you want to accomplish?

    Hi @jordanmc,

    We are going ahead and marking this issue as resolved due to inactivity. If you require any further assistance please create a new issue. Thank you!

    Thread Starter jordanmc

    (@jordanmc)

    Thanks, I figured it out. For example:

    		$seo = array();
    		// https://developer.yoast.com/blog/yoast-seo-14-0-using-yoast-seo-surfaces/
    		$robots = YoastSEO()->meta->for_post($post->ID)->robots;
    		$meta = YoastSEO()->meta->for_post($post->ID);
    
    		// Get data
    		$seo = array(
    		  'title' => trim(YoastSEO()->meta->for_post($post->ID)->title),
    		  'metaDesciptionText' => trim(YoastSEO()->meta->for_post($post->ID)->description),
    		  'metaKeywordsText' => trim(get_post_meta($post->ID, '_yoast_wpseo_focuskw', true)),
    		  //'metaKeywordsText' => trim(get_post_meta($post->ID, '_yoast_wpseo_metakeywords', true)),
    		  'twitterCardType' => trim(YoastSEO()->meta->for_post($post->ID)->twitter_card),
    		  'canonical' => trim(YoastSEO()->meta->for_post($post->ID)->canonical),
    		);
    		$myObj->seo = $seo;
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Getting yoast values in child theme functions.php’ is closed to new replies.