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
Stop Struggling With GA4
Get all the analytics info you need, without any learning curve. Check out our review of Clicky Analytics!
[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
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!
Last Updated:
