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 '<div class="your-class">'. $value .'</div>';
}
</code></pre>
}
Assumes your custom field name ( key ) is custom.
Uses the genesis_entry_content hook with a 3rd parameter of 12
Leave a Reply