• Hi,
    I am having a serious problem with < p > tags being generated inside my post excerpts.
    I am experiencing this problem now in my Starkers theme and it was NOT a problem with my Thematic theme. The designer of Starkers says it has nothing to do with his theme, so I am wondering if this is code wp is generating that thematic blocked and now starkers doesn’t?

    I had this added to my thematic functions.php, it worked perfectly

    // Improve excerpt formatting
    function improved_trim_excerpt( $text ) {
    	if ( '' == $text ) {
    		$permalink = get_permalink();	// my addition
    		$text = get_the_content( '' );
    		$text = strip_shortcodes( $text );
    		$text = apply_filters( 'the_content', $text );
    		$text = preg_replace( '@<script[^>]*?> . *?</script>@si', '', $text );
    		$text = str_replace( ']]>', ']]>', $text );
    		$text = strip_tags( $text, '<a><b><u><em><i><strong><sub><sup><font><span><dl><dt><dd>' ); // allowed tags (change as needed)
    		$excerpt_length = apply_filters( 'excerpt_length', 5000 );
    		$excerpt_more = apply_filters('excerpt_more', ' ' . ' .. <a href="' . $permalink . '">[more]</a>');	// my addition
    		$words = explode( ' ', $text, $excerpt_length + 1 );
    		if ( count( $words ) > $excerpt_length ) {
    			array_pop( $words );
    			$text = implode( ' ', $words );
    			$text = $text . $excerpt_more;
    			$text = force_balance_tags( $text );	// my addition
    		}
    	}
    	return $text;
    }
    remove_filter( 'get_the_excerpt', 'wp_trim_excerpt' );
    add_filter( 'get_the_excerpt', 'improved_trim_excerpt' );

    Now the same code added to the Starkers functions.php ALMOST works except for the random < p > that are mysteriously generating all over the my excerpts! The < p > tags only generate after the above code is added to functions.php. Again, this same code worked fine in Thematic.

    For example, here is one of my excerpts after the excerpt formatting code is added:

    <p><span class="collapse"></p>
    <p>
    Angel is currently in rescue and residing with another female.
    She was formerly a house dog living with a 3 year old child.
    She is submissive and wants to be with people and be inside.
    </p>
    <p></span></p>

    None of those paragraph tags should exist. They do not exist in the original post or when viewing the source code of single posts. I have wpautop disabled as well. The < p > tags only exist in the excerpts and only after the excerpt formatting code is added. Please help if you can.

  • The topic ‘Mystery tags appearing in excerpts, nowhere else’ is closed to new replies.