WordPress.org

Ready to get started?Download WordPress

Forums

Searching a blog - entire articles appear (6 posts)

  1. joeking
    Member
    Posted 8 years ago #

    When I enter a search phrase in my blog entire articles are returned in the search results.

    Is it possible to have just the title and a short excerpt appear instead of the full article?

  2. ColdForged
    Member
    Posted 8 years ago #

    Joe, without a link or a theme it's tough to answer definitively, but I'll give it a general guess: edit your theme's search.php file and change the line that says the_content() to be the_excerpt().

  3. moshu
    Member
    Posted 8 years ago #

    Good to know: if your theme doesn't have a search.php template then the archive.php will be used to display the search results. And given the unreasonably high number of users that have the not-so-smart idea to change the look of the archive.php to display full articles instead of the excerpt... here we go :)
    (btw, the Codex is wrong in the Template Hierarchy saying that if there is no search.php the index.php will be used.
    Edit: made the correction in Codex.)

  4. joeking
    Member
    Posted 8 years ago #

    ColdForged - you're a star!

    My theme didn't have a search.php so I borrowed and customised the default theme's one and it works a treat!

  5. SlowLove
    Member
    Posted 8 years ago #

    moshu: "btw, the Codex is wrong in the Template Hierarchy saying that if there is no search.php the index.php will be used."

    Was the Codex actually wrong about that? I just deleted the search.php file from my theme, and when I ran a search, it was processed by the index.php file, not the archive.php file, as my archives are (and which is my preference for searches).

    Are other people getting different results?

  6. rustin
    Member
    Posted 8 years ago #

    ColdForged Thanks so much for that info. I've been casually messing with that for a few days and you just made it all fall together for me. Thank ya!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.