Community Forums › Forums › Archived Forums › General Discussion › Display post meta differently on home page
- This topic has 9 replies, 2 voices, and was last updated 9 years, 6 months ago by
donmcleman.
-
AuthorPosts
-
July 29, 2015 at 7:52 am #160852
donmcleman
MemberHi, on the home page and archive pages I want to display post meta after the entry footer (and not display the entry header), whereas on the post I want to display it in the entry header (and not display the entry footer).
At the moment my hack is to display both and 'display:none' one of them using css.
I know there must be some beautiful php code that says something like 'if !home then call the header meta'... but my attempts don't work 🙂
Please can someone help?
http://staging.crosswebideas.comJuly 29, 2015 at 9:13 am #160857Brad Dalton
ParticipantTry this http://my.studiopress.com/snippets/entry-header/
Add the is_home() conditional after the function and change hooks if needed
July 29, 2015 at 10:32 am #160874donmcleman
MemberThank you, Brad! This is the code I've used and it works:
//* Customize the entry meta in the entry header (requires HTML5 theme support) add_filter( 'genesis_post_info', 'sp_post_info_filter' ); function sp_post_info_filter($post_info) { $post_info = '[post_date]'; if( !is_home() ) return $post_info; } //* Customize the entry meta in the entry footer (requires HTML5 theme support) add_filter( 'genesis_post_meta', 'sp_post_meta_filter' ); function sp_post_meta_filter($post_meta) { $post_meta = '[post_date]'; if( is_home() ) return $post_meta; }
I'd also like to remove the footer mark-up on the post as I've given it a border. I thought the following code would work but it doesn't – my php skills are minimal so I can't see what's wrong:
//* Remove the entry footer markup (requires HTML5 theme support) add_filter( 'genesis_entry_footer', 'crosswebideas_footer_markup'); function crosswebideas_footer_markup() { if( !is_home() ) remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 ); remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 ); }
Please do you have any suggestions for this part?
July 29, 2015 at 10:42 am #160876Brad Dalton
ParticipantConditional tags should come immediately after the function.
Please start a new topic for your question relating to the footer markup.
July 29, 2015 at 10:48 am #160877donmcleman
MemberSorry, Brad, I didn't know what this means: 'Conditional tags should come immediately after the function.' You can't mean after the closing curly bracket?
July 29, 2015 at 11:46 am #160885Brad Dalton
ParticipantHere's how you should use them:
add_filter( 'genesis_post_meta', 'sp_post_meta_filter' ); function sp_post_meta_filter($post_meta) { if( is_home() ) $post_meta = '[post_date]'; return $post_meta; }
July 29, 2015 at 12:32 pm #160889donmcleman
MemberWell, I would never have worked that out... I must take some sort of intro course.
Thank you!
July 29, 2015 at 12:44 pm #160893donmcleman
MemberWell, it doesn't actually work... I can see that format working for other functions but it's not working with this one.
This posts both the footer meta and the header meta:
add_filter( 'genesis_post_info', 'sp_post_info_filter' ); function sp_post_info_filter($post_info) { if( !is_home() ) $post_info = '[post_date]'; return $post_info; } add_filter( 'genesis_post_meta', 'sp_post_meta_filter' ); function sp_post_meta_filter($post_meta) { if( is_home() ) $post_meta = '[post_date]'; return $post_meta; }
Any explanation?
July 30, 2015 at 1:51 am #160922Brad Dalton
ParticipantThe position of your conditional tag is correct.
Do you have the Genesis Simple Edits plugin activated?
July 30, 2015 at 1:56 am #160923donmcleman
MemberHi, I don't have that plugin installed, I'm trying to cut down on the number of plugins I use so I'd really prefer a code solution.
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.