ThemeShaper Forums » Thematic

[closed]

Mystery < p > tags appearing in excerpts, nowhere else

(2 posts)
  • Started 10 years ago by Seijun
  • Latest reply from em hr
  • This topic is not resolved

Tags:

  1. Hi,
    I am having a serious problem with < p > tags being generated inside my post excerpts.
    I actually no longer using thematic as my primary theme, instead I am working on a theme built from Starkers. However, I am experiencing this problem now in my Starkers theme and it was NOT a problem with Thematic. The designer of Starkers says it has nothing to do with his theme, so I am wondering if there was some code in thematic that was actively preventing this issue, and what it might have been so I can add it to my new theme. Here is my problem:

    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.

    Posted 10 years ago #
  2. You should try the http://wordpress.org/support forums for themes other than Thematic and family.

    Try searching there for wpautop() That is the function that you likely need to remove from filtering your excerpts.

    Posted 10 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.