Support

Account

Home Forums Front-end Issues Custom fields for excerpt

Helping

Custom fields for excerpt

  • Hello, i found some code, which outputs an arbitrary field in the announcement.

    //dispay acf field in excerpt
    function custom_field_excerpt() {
    
    	global $post;
    
    	$text = get_field('filedname');
    
    	if ( '' != $text ) {
    
    		$text = strip_shortcodes( $text );
    
    		$text = apply_filters('the_content', $text);
    
    		$text = str_replace(']]>', ']]>', $text);
    
    		$excerpt_length = 60; // 20 words
    
    		$excerpt_more = apply_filters('excerpt_more', ' ' . '[Hello...]');
    
    		$text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
    
    	}
    
    	return apply_filters('the_excerpt', $text);
    
    }

    But a single field is displayed. Help please, bring a few fields in the announcement.

  • Hi @tapioka

    I’m sorry I’m not sure what is the problem. Could you please share some screenshots of the issue?

    Thanks!

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.