Display excerpts on search results page

Community Forums Forums Design Tips and Tricks Display excerpts on search results page

This topic is: not resolved

This topic contains 3 replies, has 2 voices, and was last updated by  nutsandbolts 11 months, 2 weeks ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #70870

    blackartz
    Participant
    Post count: 2

    Hi there,
    can anyone tell me what conditional argument I need too include in my functions.php to force the_excerpt(); to be displayed on the search results page, but the_content(); on all other archives?

    So far I have this but it doesn’t work :(

    add_filter('the_content', 'my_excerpts');
    function my_excerpts() {
    if( is_search(){
    	the_excerpt();
    } else {
    	the_content();
    }

    Any advice gratefully recieved :)

    #70927

    nutsandbolts
    Moderator
    Post count: 3140

    Try this and see if it works for you:

    add_action( 'genesis_before', 'my_excerpts' );
    function my_excerpts() {
        if( is_search() ) {
            the_excerpt();
        }
    }

    Andrea Whitmer, Owner, Nuts and Bolts Media
    I provide dev and training services for web designers • Find me on Twitter and Google+

    #70967

    blackartz
    Participant
    Post count: 2

    Hi Anrdea,
    thanks for trying but this doesn’t work :(

    I still get the_content displayed on my search results page.

    I wonder if its easier for me to change the site to display the excerpt site wide, then specify which category archives should show the content?

    #70968

    nutsandbolts
    Moderator
    Post count: 3140

    Could be. I’ll never understand why the theme settings don’t include different options for different types of archive pages.


    Andrea Whitmer, Owner, Nuts and Bolts Media
    I provide dev and training services for web designers • Find me on Twitter and Google+

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.