ThemeShaper Forums » Thematic

[closed]

Missing paragraph tags in the_excerpt

(3 posts)
  • Started 11 years ago by allancole
  • Latest reply from allancole
  • This topic is resolved
  1. So it looks like the_excerpt isn’t being wrapped in paragraph() tags.

    I think this is what a few users were hinting at in this previous post:
    http://forums.themeshaper.com/topic/styling-excerpts

    I may be going about this wrong but I tried bringing the tags back by adding a wpautop filter but to no avail:

    add_filter('the_excerpt', 'wpautop');
    add_filter('thematic_the_excerpt', 'wpautop');
    add_filter('thematic_trim_excerpt', 'wpautop');

    Any other ideas?

    Posted 11 years ago #
  2. Hi Allan-

    You may know but for those who don't here's a little background info to help with this example... wpautop is a function with which to pass a string through for formatting. WordPress does filter the_content and the_excerpt with wpautop() before displaying the data.

    Thematic is using get_the_excerpt in thematic_content() WordPress generally uses get_the_fill-in-the-blank as a function to store data rather while the_fill-in-the-blank will usually display the data. I thought get_the_excerpt was wpautop'ed. Maybe it's been trimmed somewhere else in thematic. Anyway if you want to put the p's in try this:

    function child_excerpt_autop() {
    	global $content;
    
    	if ( strtolower($content) == 'full' ) {
    		$post = get_the_content(more_text());
    		$post = apply_filters('the_content', $post);
    		$post = str_replace(']]>', ']]>', $post);
    	} elseif ( strtolower($content) == 'excerpt') {
    		$post = get_the_excerpt();
    
    		// add in the <p>
    		$post = wpautop($post);
    		// add a class if you like
    		$post =	preg_replace('/<p>/', '<p class="autop">', $post); 
    
    	} elseif ( strtolower($content) == 'none') {
    	} else {
    		$post = get_the_content(more_text());
    		$post = apply_filters('the_content', $post);
    		$post = str_replace(']]>', ']]>', $post);
    	}
    	return $post;
    }
    add_filter('thematic_post','child_excerpt_autop');

    This is a valid filter but it won't work because the $content hasn't been globalized in the original function. The filter is doesn't really work without the global. One more thing for Chris's to do list. Until he adds the global or finds a better solution you can manually add global $content; to thematic_content() and then this will work for you.

    -Gene

    Posted 11 years ago #
  3. AHHH. Makes perfect sense. Yeah I noticed another instance where a function needed some global $posts; love. I’ll probably just hold out for the next stable Thematic release. Thanks for sorting this out!

    — Allan

    Posted 11 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.