Support » Plugins » Want to customize search results to show summary of posts

  • Resolved cmortazavi13


    Hi i am kinda new and i was hoping i could get some help with a small issue. I am using WP custom fields search to have users search through my post and i want the results of my search to be displayed in a certain way. Right now the entire posts are being displayed and i only want a list of the post titles to be displayed along with a one sentence summary of the posts. I do not want the summary to be the first 50-something words of the post i would like to have a one sentence summary of the post that is independent of the post content (even thought it is summarizing it). Any help you guys could give me would be much appreciated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • If you are not using post excerpts for any other purpose, you could use the built in WordPress manual excerpt feature to store your one sentence post summaries, and then change the search page to display the post excerpt instead of the full post content.

    1) Nowadays the post excerpt box is hidden by default. On the Post edit page, click screen options in the upper right corner and put a check in Excerpts. That reveals the excerpts entry box. When a manual excerpt exists on a post WordPress will display that rather than the default first 55 words of the post, when an excerpt is being displayed.

    2) If you want to have the Visual Editor on the excerpts box (its optional – you can use HTML tags in the box without the editor) install this plugin

    3) Then you have to edit your search results template and replace
    the_content() with the_excerpt(); There may be code between the parentheses of the_content() – that’s fine. Its not needed with the_excerpt(). If you are not too familiar with editing code the best bet is make a backup copy of the search template before you change anything so if you run into issues you can go back to how it was before you changed it.

    Here’s an old article about manual excerpts.
    You really don’t need an additional plugin to do this (other than possibly the visual editor plugin I mentioned).

    This should get you started.

    Thank you so much this was a huge help and this was exactly what i was looking for. I didn’t even know about the screen options and how i could add different criteria for my posts. I was also wondering how i could display my custom fields and have my posts ordered by those custom fields in the search results. SO for example i want to add a custom field where the key is “author” and the value= the authors name and this would be viewable to the user on search results pages and on the post itself and i want to add another custom field where the key is “article” and the value is a number and the posts are ordered by the article number in the search results page from least to greatest. Any help you could give me would be great because as of right now I’m having a hard time even displaying my custom fields on my posts or my search results page.

    What you wish to do requires PHP coding changes to alter the default WordPress query that is run to produce the search results.

    I’ve not used this plugin but it might let you do what you want

    Query Posts Widget: WordPress Plugin

    If not you need some code changes. The raw instructions are here:

    If you have little experience with PHP coding you may not find the raw instructions easy to follow. Basically you have to override the default query parameters before the WordPress loop on the search page.

    What you want is not especially involved for someone who knows their way around WordPress. It would be a bit tricky as a learning project. It sounds like you need a custom search form too because you need a way for people to indicate how they want their search results ordered. Then that order has to be passed to the search results page so its included in the query that runs the search.

    I can’t recall any articles describing creating a process like that. You could Google for WordPress customize search results as a starting place

    thank you very much for your help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Want to customize search results to show summary of posts’ is closed to new replies.