• Resolved billystoner

    (@billystoner)


    Hey Sybre,

    I’d like to show Meta Description on Author Pages from an ACF Field.

    Do you have a code snippet for this case?

    Thanks in advance!

    Martin

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

    (@cybr)

    Hi Martin,

    You can use filter the_seo_framework_fetched_description_excerpt, test for null === $args && is_author(), and then return the value of get_field().

    You still need to change ‘my_author_desc_field’ to something you added. e.g.:

    add_filter( 'the_seo_framework_fetched_description_excerpt', function( $excerpt, $depr, $args ) {
    
    	if ( null === $args ) {
    		// In the loop
    		if ( is_author() ) {
    			$field = function_exists( 'get_field' ) ? get_field( 'my_author_desc_field', get_the_author_meta( 'ID' ) ) : '';
    
    			// AI-strip all its HTML and shortcodes. (Optional but neat if field accept raw input)
    			$field = $field ? tsf()->s_excerpt_raw( $field ) : '';
    
    			// Use $field if it has content, otherwise fall back to original excerpt.
    			$excerpt = $field ?: $excerpt;
    		}
    	}
    
    	return $excerpt;
    }, 10, 3 );

    I hope this helps! Cheers ??

    Thread Starter billystoner

    (@billystoner)

    Hey Sybre, thanks a lot! You’re always very helpful, Cheers

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Meta Description on Author Pages’ is closed to new replies.