Forums

[resolved] I would like only a part of the post text as a search result (6 posts)

  1. TH
    Member
    Posted 5 years ago #

    I would like to have only a part of the post text as a search result and not the entire post. How do I set that?

    My theme has a searchform php file and I am currently using the Search Reloaded plugin on WP 2.1.1. The search is in the sidebar but it is not a Widget.

    ?

  2. Otto
    Tech Ninja
    Posted 5 years ago #

    The 'search.php' template file is where the results of searches are displayed. Customize that file to change how the search results look.

  3. drmike
    Member
    Posted 5 years ago #

    Take a look at your theme's search.php file. Chances are it's displaying the text of your post using the the_content function. Change it to use the the_excerpt function.

    Details here: Template_Tags/the_excerpt

    Hope this helps,
    -drmike

  4. TH
    Member
    Posted 5 years ago #

    This explains why I couldn't find any code for it. I don't actually have a search.php file! Guess I'll have to steal one from the default theme and see how that works. (I wonder where it went though. I'm sure there was one before)

    Thanks a lot guys!

  5. Otto
    Tech Ninja
    Posted 5 years ago #

    You can just copy the index.php file into a search.php file, then modify it as you see fit. All templates are similar in design, the only reason you would have a search.php is because you customized it.

  6. TH
    Member
    Posted 5 years ago #

    Thanks Otto. Everything is starting to make more sense now.

    I got it to work just fine so now I'm happy.

    Thanks again everyone!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.