Forum Replies Created

Viewing 2 replies - 16 through 17 (of 17 total)
  • Thanks keeslemeljer. Allthough that didn’t seem to do the work. But you have a good point with the possibility of breaking the html.

    Do you, or anyone else have a good suggestion on how to make a advanced cusomt field equivalent to the_content but with word limit and a read more tag without using the devider in the editor? Do you know what I mean?

    In thought, that would make an excerpt but with the “the_content” tag instead. That wouldn’t break my html would it?

    To pull data from my advanced custom field wysivyg editor I use <?php the_field('innehall'); ?>. How can I put an automatic word limit to that tag and also display a reda more tag if it exceeds the word limit?

    Thanks again!
    Jeppe

    https://jeppeblomgren.se

    Hi all. Great post!
    I’m trying to get the excerpt made above to show tags. In other words, i want to show <a>, <strong> etc. in the excerpt. Any ideas on how to add that?

    I tried this. Doesn’t work.

    function custom_excerpt() {
    	global $post;
    	$text = get_field('innehall');
    	if ( '' != $text ) {
    		$text = strip_shortcodes( $text );
    		$text = apply_filters('the_content', $text);
    		$allowed_tags = '<p>,<a>,<em>,<strong>,<img>';
    		$text = strip_tags($text, $allowed_tags);
    		$text = str_replace(']]>', ']]>', $text);
    		$excerpt_length = 40; // 20 words
    		$excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
    		$text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
    	}
    	return apply_filters('the_excerpt', $text);
    }
Viewing 2 replies - 16 through 17 (of 17 total)