Genesis: How to place the post meta and info just on single pages
I’ve been working with the Genesis Framework for WordPress lately, and I recently discovered there are two ways to make Genesis display the post meta and info conditionally, and which method you need depends whether the theme is HTML5 or not.
On most sites, I use excerpts on the front page, and most Genesis themes place the post meta and post info – that’s the author byline, categories, tags and so on – on every excerpt by default. That’s a lot of extra links on my homepage. I prefer to only show that information in the single.php or article view. So here’s the code to make that happen. You plonk this into your functions.php file.
For older, non-HTML5 themes
[php]//* Remove post meta from archive pages
remove_action(‘genesis_after_post_content’, ‘genesis_post_meta’);
remove_action(‘genesis_before_post_content’, ‘genesis_post_info’);</code>
<code>add_action(‘template_redirect’, ‘child_conditional_actions’);
function child_conditional_actions() {
if( is_single() ) {
add_action(‘genesis_after_post_content’, ‘genesis_post_meta’);
add_action(‘genesis_before_post_content’, ‘genesis_post_info’);
}}[/php]
For HTML5 Genesis themes
[php]//* Remove post meta from archive pages
remove_action(‘genesis_entry_footer’, ‘genesis_post_meta’, 12);
remove_action(‘genesis_entry_header’, ‘genesis_post_info’, 12);</code>
add_action(‘template_redirect’, ‘child_conditional_actions’);
function child_conditional_actions() { if( is_single() ) {
add_action(‘genesis_entry_footer’, ‘genesis_post_meta’, 12);
add_action(‘genesis_entry_header’, ‘genesis_post_info’, 12);
}}[/php]
Additional Notes
Got downtime with your current host? Switch to the best host you've never heard of - TigerTech! I've used them for over a decade - great speed, excellent security, and all my sites together have had maybe an hour of downtime altogether in all those years.
On some Genesis themes, you may have to remove one of the “add_action” lines because it’s already added back in elsewhere in your functions.php file.
Got any questions? Just ask!
By:
Chris W. ~ Last Updated:
