• Hello,

    I’m using ACF fields for page content, with lots of repeaters and flexibles fields, and when I look at the SEO Box the meta description is not empty thanks to the plugin “ACF Content Analysis for Yoast SEO” but when I look in the code, the meta description doesn”t show up and I have a notice to inform me that the page doesn”t have a meta description.

    Is there a way to retrieve the meta description with the content of acf field ?

    thanks a lot

Viewing 1 replies (of 1 total)
  • Hi annelyse

    I was in the same situation.
    You just don’t need an extra plugin for this.
    Yoast native filters are your friend. ??

    https://yoast.com/wordpress/plugins/seo/api/

    // Meta Description with ACF Content for Single Events
    add_filter(‘wpseo_metadesc’, ‘show_event_description’, 10, 1);

    function show_event_description( $str ) {
    
        // e.g. only Single 'Event' page
        if ( is_singular( 'event' ) ) {
    
            $str = '';
    
            $content = get_field('acf_content');
    
            $str = sanitize_text_field( mb_substr($content, 0, 300, 'UTF-8') ); 
        }
        return $str;
    }

    Cheers,
    Chris

Viewing 1 replies (of 1 total)
  • The topic ‘Meta description and ACF field’ is closed to new replies.