Forum Replies Created
-
AuthorPosts
-
mikefergMember
Ren, I forgot to post up my block of code should anyone else wish to do something similar.
// Adds custom field "price" to single posts and post archives
add_action( 'genesis_entry_header', 'custom_field_before_content', 15 );
function custom_field_before_content() {
if ( 'post' == get_post_type() )
echo '<div class="price">£ '. genesis_get_custom_field('price') .'</div>';
}mikefergMemberThanks Ren, I think this topic can close now.
mikefergMemberHi Ren, thanks for the reply.
I worded my question poorly. The custom field needs to display in both post and post archive.
I have got it to display in the post by adapting this bit of code and placing it in child functions.php:
add_action( 'genesis_entry_header', 'custom_field_before_content', 15 );
/**
* @author Brad Dalton
* @example http://wpsites.net/
* @copyright 2014 WP Sites
*/
function custom_field_before_content() {
if ( is_singular(array( 'post', 'page')) && genesis_get_custom_field('price') ) :
echo '<div class="price">£ '. genesis_get_custom_field('price') .'</div>';
endif;
}I am now looking for a similar bit of code to echo a custom field in a post archive. That is where I am stuck now.
I followed your links but was unable to find the solution I am looking for. I am still getting to grips with how Genesis does things so the solution may well be staring me in the face but I just can't see it.
Cheers
Mike -
AuthorPosts