WordPress.org

Ready to get started?Download WordPress

Forums

Search Excerpts? (8 posts)

  1. ashes999
    Member
    Posted 8 years ago #

    I would like to modify my search functionality to include excerpts. How can I do this? I have an idea of how to rewrite the SQL statement, if the search query executes and SQL statement -- just point me in the right direction!

  2. niziol
    Member
    Posted 8 years ago #

    If I have a handle on what you want to do, you would just need to modify: the_content() tag in your search template to the the_excerpt() tag. Read the codex articles on Template Tags. I can't see any possible reason that you would need to hack anything to do this simple, documented task.

    Cheers,
    Michael.

  3. Kafkaesqui

    Posted 8 years ago #

    Michael, that would display search results with the excerpt, but would not actually *search* excerpt field content.

    ashes, see if Jerome's Search plugin works for you:

    http://vapourtrails.ca/wp-plugins

  4. niziol
    Member
    Posted 8 years ago #

    I think ashes needs to clarify his/her question, as it is very ambiguous as to what exactly he/she wants done.

    Why would one want to specifically search the excerpt fields, excerpts are by definition an excerpt of the content and search already searches the content, doesn't it?

  5. TechGnome
    Moderator
    Posted 8 years ago #

    niziol - it seems perfectly clear to me.... search the excerpt instead of the content. The excerpt isn't necessarily from the content anyways. It depends on how you use it. I use it as a teaser, and so my excerpts don't repeat what's in the actual content. I could think of serval reasons for wanting to search the excerpt instead of the content.

    -tg

  6. Kafkaesqui

    Posted 8 years ago #

    Excerpts are by definition just what you believe them to be: a brief excerpt of a post's content. However, one can put just about anything they want in the excerpt field of a post, from an actual summary or excerpt of the post's content to introductory text, an image, a personal note. Anything.

    When an actual exerpt exists, the_excerpt() will display that (rather than an excerpt of post content). WordPress does not touch this particular field when using the built-in search functionality.

  7. ashes999
    Member
    Posted 8 years ago #

    Sorry, I'll clarify.

    I need to modify the Search field on my blog so that it searches not only article content, but also article excerpts.

    The reason? Sometimes I reference things in my article, but don't put the full name, except in the excerpt; so the excerpt contains content that lets you identify something from out-of-context, which is useful sometimes.

    This is because I use different words in the excerpt and the article (slightly, but they have major ramifications to searchability).

  8. ashes999
    Member
    Posted 8 years ago #

    The plugin worked--thanks, Kafkaesqui! EXACTLY what I needed!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags