Hi Garrett,
The best filter would be the_seo_framework_generated_description.
e.g.:
add_filter( 'the_seo_framework_generated_description', function( $description, $args ) {
$custom_description = '';
if ( function_exists( 'get_field' ) ) {
$custom_description = get_field( 'field-name' );
}
// Return custom description if set, otherwise fall back to default.
return $custom_description ?: $description;
}, 10, 2 );
The code above will let your field act like a “generated” description if set. With that, you can drop the other filter adjustments 🙂
If you wish to disable the generation of the description when that field is found, then this filter would work nicely in company:
add_filter( 'the_seo_framework_enable_auto_description', function() {
// Disable autodescription if the field is not empty; Caution: '0' counts as empty.
return ! ( function_exists( 'get_field' ) && get_field( 'field-name' ) );
} );
Hey Sybre,
Thanks for the quick response! I have replaced the 3 filters with the ‘the_seo_framework_generated_description’ and it works like a charm! However, I am still seeing the original description generated from the content (not the custom field output from the_seo_framework_generated_description) as the placeholder for the Custom Post Description field in Post SEO Settings on the post edit page. Is there any way to filter so that the placeholder uses the custom field description I altered in the the_seo_framework_generated_description filter as well? Seems like that placeholder should be using the description output from the filter?
Thanks,
Garrett
Hey Sybre,
Wanted to follow up on this – is there anyway to update the placeholder for the Custom Post Description field in Post SEO Settings on the post edit page to show the custom description from a custom field?
Thanks,
Garrett