• I have a function to put tags back into the excepts on my front page. I’ve put this in three sites that are using the same basic theme, based on Genesis Sample.

    Here is the function. You’ll see the paragraph and link tags specified in the eighth line.

    function my_custom_excerpt($text) {
    	global $post;
    	if ( '' == $text ) {
    		$text = get_the_content('');
    		$text = apply_filters('the_content', $text);
    		$text = str_replace('\]\]\>', ']]>', $text);
    		$fulltext = str_replace('\]\]\>', ']]>', $text);
    		$text = strip_tags($text, '<em><p><a>');
    		$excerpt_length = 100;
    		$words = explode(' ', $text, $excerpt_length + 1);
    		if (count($words) > $excerpt_length) {
    			array_pop($words);
    			array_push($words, '... <a href="'. esc_url( get_permalink() ) . '">Read more ?</a>');
    			$text = implode(' ', $words);
    		}
    		else {
    			$text = $fulltext;
    		}
    	}
    	return $text;
    }
    remove_filter('get_the_excerpt', 'wp_trim_excerpt');
    add_filter('get_the_excerpt', 'my_custom_excerpt');

    Site #1 was developed first. The code is not working on the excerpts.

    Site #2 and #3 were made from tweaks of Site #1. It’s the same basic design, as you’ll notice if you take the links.

    Site #2 also has the code not working.

    Site #3 is the site where the function is working correctly. This baffles me. I’ve looked into plug-ins as a possible culprit, #1 has a lot, #2 has many, and #3 not so much. I tried turning #2’s plugins off one by one to see if that would be the reason to allow the function to work. But no success.

    I look at the HTML and #3’s content clearly has <p> and <br> tags in it. Does anyone have any insight what I could do to determine why #3 is working, so that I can fix #1 and #2?

    Thanks.

    • This topic was modified 7 years, 8 months ago by David Borrink.
  • The topic ‘Putting tags back in excerpts, works in one of three “identical” sites’ is closed to new replies.