The code in this download folder enables you to customize your search results. In this case, the code enables you to limit the content by number of words for standard post types as well as specific custom post types you name in the code.
This way you can show a customized excerpt of any length with a customized link back to the single entry. If a custom field has been added, this will also display as seen in the following image.
The image shows 3 entries returned when searching using CPT as the query.
- The 1st entry prints the custom field value for the portfolio CPT followed by ( limited ) content for the same entry.
- The 2nd entry prints the ( limited ) content for the property CPT. NO custom field value is printed as none added.
- The 3rd entry prints the custom field value for the standard post type followed by ( limited ) content for the same entry.
Demo Video #
Shows limited ( by word ) content and custom field values for standard and custom post types, if it exists, on the search results page.
Tested using the Genesis Sample child theme by StudioPress. Works in any Genesis child theme and any WordPress parent theme.
Code Installation – From Download Folder #
There’s only 1 step :
Copy the PHP code to the end of your child themes functions file.