Looking to modify the entry meta or post info in the entry header in your Genesis site but only on specific single posts?
We can do this by wrapping the code inside a if condition that checks for IDs of selected posts in the function that is hooked to genesis_post_info
.
Adding the following sample code in child theme’s functions.php
will change the default post info,
[post_date] by [post_author_posts_link] [post_comments] [post_edit]
to
[post_date] [post_comments] [post_edit]
i.e., remove the “by <author name”> part from the post info on posts having these IDs: 20 and 447.
add_filter( 'genesis_post_info', 'sk_post_info_filter' );
/**
* Modify post info in entry header on select single posts.
*/
function sk_post_info_filter( $post_info ) {
if ( is_single( array( '20', '447' ) ) ) {
$post_info = '[post_date] [post_comments] [post_edit]';
}
return $post_info;
}
You would need to set your desired shortcodes in the code above and importantly, change the IDs to the IDs of posts that should be affected.
References
https://my.studiopress.com/documentation/snippets/entry-header-html5/customize-the-entry-header/
https://developer.wordpress.org/reference/functions/is_single/#comment-496
Thank you, exactly what I’ve been looking for!