ThemeShaper Forums » Thematic

[closed]

Multiple Excerpt Styles

(9 posts)
  • Started 10 years ago by helgatheviking
  • Latest reply from helgatheviking
  • This topic is not resolved

Tags:

  1. I've come back to the idea of having 2 styles of excerpts... say 1 that is short w/ all the tags stripped out and 1 that is longer with a few tags left in such as and .

    I found a couple of sites on the subject, but nothing really seems right. tho maybe the solution will come to me w/ some fresher eyes.

    has anybody ever done this? any slick insights? does it make sense to try to duplicate the whole excerpt function? get_the_excerpt really should accept some parameters... at the very least length.

    Posted 10 years ago #
  2. I think your post got fragged somehow. Did you intend to post a link?

    Overriding thematic_content to create two forms of excerpts is the path I'd take.

    In terms of triggering which excerpt shows where, You could use conditional tags in thematic_content_init, custom fields from the post, or filter the_content in thematic_content looking for a custom comment block like the more tag i.e. <!--more -->.

    Posted 10 years ago #
  3. yeah there is not supposed to be a link in there. i'm not sure what happened. i'm going to try overriding the entire thematic_content_init and thematic_content functions like i have done before. i am not sure why i have been reluctant to do it that way. is there no way to filter in just the conditions that i want to add?

    Posted 10 years ago #
  4. another thing- i am sort of at a loss as to how to define my 2nd excerpt conditionally. I'm using a loop to put content in the sidebar above the widget areas, but since it is a loop !(in_the_loop()) doesn't work, and thematic_content needs to be in the loop anyway. can't use is_home() or things that match post type as i want excerpts in the content area to stay normal. so basically i need to target 1 loop and not the other.

    still working on this one...

    Posted 10 years ago #
  5. What I was describing was meant for providing different styles of content or excerpts in the main loop.

    Do you want the normal Thematic loop with one type of excerpt and then a new loop above the main asides that outputs a second kind of excerpt?

    btw I've been trying to get to you via email. Any of it get through?

    Posted 10 years ago #
  6. hi gene, yes i am looking for 1 type of excerpt for the normal loop and another type above the main asides. actually i think i have almost got it sorted. i did get an email from you (my site is basically defunct and my new portfolio site never seems to get done) and will write you back soon.

    Posted 10 years ago #
  7. how come this never seems to work?

    //change default excerpts to my_excerpts
    function childtheme_excerpts($post) {
    	global $thematic_content_length;
    
    		if ( strtolower($thematic_content_length) == 'excerpt' ) {
    	$post = '';
    	$post .= my_excerpt('long','ellipse');
    	}
    	return $post;
    }
    
    add_filter('thematic_content', 'childtheme_excerpts');

    is the only way to redefine the 'excerpt' content type to use the override?

    function childtheme_override_content() {
    		global $thematic_content_length;
    
    		if ( strtolower($thematic_content_length) == 'full' ) {
    			$post = get_the_content(more_text());
    			$post = apply_filters('the_content', $post);
    			$post = str_replace(']]>', ']]>', $post);
    		} elseif ( strtolower($thematic_content_length) == 'excerpt') {
    			$post = '';
    			$post .= my_excerpt('long', 'permalink');
    			$post = apply_filters('the_excerpt',$post);
    
    		} elseif ( strtolower($thematic_content_length) == 'none') {
    		} else {
    			$post = get_the_content(more_text());
    			$post = apply_filters('the_content', $post);
    			$post = str_replace(']]>', ']]>', $post);
    		}
    		echo apply_filters('childtheme_override_content', $post);
    
    } // end content
    Posted 10 years ago #
  8. Function names and the filters inside of them are not always interchangeable. There is no thematic_content filter hook.

    Try:
    add_filter('thematic_post', 'childtheme_excerpts');

    When things don't work when you think they should, it's always best to look back at Thematic's source.

    Posted 10 years ago #
  9. VICTORY! i spend so much time in the extensions folder i can't believe i didn't see that. thanks gene!

    Posted 10 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.