• Resolved gratrockstar

    (@gratrockstar)


    Hi there,
    We want to use content from a ACF field as the meta and social descriptions – I’ve been able to make that work using the the_seo_framework_description_output, the_seo_framework_ogdescription_output, and the_seo_framework_twitterdescription_output filters. What we are looking for now is a way to alter the placeholder that shows in the Custom Post Description field on the post edit screen, so users won’t be confused that it doesn’t match what’s showing up in posts. I’ve been over the code and don’t see any filter in place to alter that to match what we’re generating from the custom field. Is this supported? And if so, what filter would be used?
    Thanks,
    Garrett

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    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' ) );
    } );
    Thread Starter gratrockstar

    (@gratrockstar)

    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

    Thread Starter gratrockstar

    (@gratrockstar)

    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

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Post Edit Description Placeholder’ is closed to new replies.