• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2784

Original Genesis Tutorials & 6000+ Guaranteed Code

Snippets

  • Consultation
  • Full Access
  • Log in

Custom Fields On Search Results Page

This tutorial provides 2 solutions which enable you to display custom fields on your search results page in Genesis.

Solution 1

This solution uses a search.php file in your child themes root directory.

Solution 2

This solution uses a conditional tag is_search from your child themes functions.php file.

add_action( 'genesis_entry_content', 'custom_fields_search_page', 12 );
function custom_fields_search_page() {

<pre><code>if ( ! is_search() ) {
    return;
}

$value = get_post_meta( get_the_ID(), 'custom', true );

if ( ! empty( $value ) ) {

echo '&lt;div class="your-class"&gt;'. $value .'&lt;/div&gt;';

}
</code></pre>

}

Assumes your custom field name ( key ) is custom.

Uses the genesis_entry_content hook with a 3rd parameter of 12

Related Code Snippets

  • Custom Fields On AgentPress Search Results Page
  • Genesis Search Results Template You Can Fully Customize

Custom Fields

Reader Interactions

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

Code written by Brad Dalton specialist for Genesis, WooCommerce & WordPress theme customization. Read More…

Advertise · WPEngine · Genesis · Log in

  • Access Problems
  • Account Details
  • Consulting
  • Tags