Skip Navigation

[Resolved] I need to make custom fields compatible with yoast can you help with this code?

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to get help making custom field values accessible by Yoast SEO.

Solution: Our developers are working on integration between Yoast and custom field values, and we hope to have this released very soon.

100% of people find this useful.

This support ticket is created 6 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 3 voices.

Last updated by Christian Cox 6 years, 6 months ago.

Assisted by: Christian Cox.

Author
Posts
#923889

I built a site for a client using custom fields and cred as they were unable to use a basic page builder.

They now want to use yoast but it will not analyse the custom fields

I was wondering if you could help me change this code to make it work with toolset?

I have full ftp access to the site and a child theme active

many thanks.

<?php
/**
* Add toolset Fields to Keyword evaluation for Yoast SEO Plugin
* @link hidden link
*/
if ( is_admin() && defined('WPSEO_VERSION') ) { // check to make sure we aren't on the front end
add_filter('wpseo_pre_analysis_post_content', 'add_acf_to_yoast');
function add_acf_to_yoast( $content ) {
global $post;
$pid = $post->ID;
$custom_content = '';
$custom = get_post_custom($pid);
unset($custom['_yoast_wpseo_focuskw']); // Don't count the keyword in the Yoast field!
foreach( $custom as $key => $value ) {
if( substr( $key, 0, 1 ) != '_' && substr( $value[0], -1) != '}' && !is_array($value[0]) && !empty($value[0])) {
$custom_content .= $value[0] . ' ';
}
}
$content = $content . ' ' . $custom_content;

return $content;
remove_filter('wpseo_pre_analysis_post_content', 'add_acf_to_yoast'); // don't let WP execute this twice
}
}
?>

#924014

YOAST requires a quite special piece of integration to work with content outside the native post editor.

But, happens we are about to finish an integration that does just that.

This is not too far away but I cannot state an ETA yet.

Please stand by for Blog Updates.

#924102

That is great news I will stop dissecting the ns custom post field plugin then.

I look forward to it's release.

#924255

Changing ticket status.