Use Custom Field Content For A Custom Post Type In Genesis Search Results

This code enables you to alter the content shown on the search results page in Genesis child themes. In this example, the default content is replaced with the content you add to a custom field named cpt_search.

custom fields

This tutorial is based on a request from a member who wanted to create custom excerpts for CPT entries to be displayed on the search results page.

Here’s an example showing the 1st entry on the search results page displaying the custom field content and the 2nd entry showing the default excerpt based on the Genesis > Theme Settings > Content Archive settings :

custom-search-results-excerpts

Watch the following demo video to see how it works :

Demo Video #

Shows custom field content displaying on the search results page if added otherwise the default excerpt is displayed.

Code Installation #

There’s only 1 step :

Related Tutorials


Comments

2 responses to “Use Custom Field Content For A Custom Post Type In Genesis Search Results”

  1. Tim Burkart Avatar
    Tim Burkart

    Thank you for the solution, Brad! I thought it worked until I coded the CSS for my CPT content. The class name is not output with the rest of the content.

    I have two additional requests:

    1) How can your solution be modified to display multiple custom fields, each on a new line?
    2) How can the solution be modified to include the post excerpt along with the custom fields?

Leave a Reply

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.