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

WP SITES

2662

Original Genesis Tutorials & 5000+ Guaranteed Code

Snippets

  • Support
  • Newsletter
  • Videos
  • Log in

Premium Member? - Request custom code

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

PHP Code

template_include

get_body_class

if else

array

class_exists

foreach

sprintf

add_action

printf

variable

Advertise · WPEngine · Genesis · Log in

  • How Premium Membership Works
  • Sign Up
  • Support
  • Subscription Details/Invoice
  • Tagged Tutorials
  • Access-Download Problems