So as I was working through a site, I just wanted to randomly remove some post meta based on the site layout. So I thought, though unique, this may be helpful to someone sometime somewhere sooner or later.
First, by default, the post meta appears in the genesis_after_post_content hook. So you need to add an action for any hook before that hook to run the test to tell WordPress/Genesis to remove post meta or not.
Second, for the check, I wanted to remove it if it were for any other post types other than post and for any posts that was full width.
Then I remove the action that calls the post meta.
[php]
add_action ( 'genesis_post_content' , 'wps_post_meta_check' );
function wps_post_meta_check() {
global $post;
if ( ( $post->post_type != 'post' ) || ( genesis_site_layout() == 'full-width-content' ) )
remove_action( 'genesis_after_post_content', 'genesis_post_meta' );
}
[/php]
Thanks for the code. Do you know how to remove the “post_meta” on the search results page JUST for pages?
Hello bMiller,
I believe this may help you. This will remove the post meta from search result pages.
[php]
add_action ( ‘genesis_post_content’ , ‘wps_post_meta_check’ );
function wps_post_meta_check() {
global $post;
if ( is_search() )
remove_action( ‘genesis_after_post_content’, ‘genesis_post_meta’ );
}
[/php]
Thanks for this post! Very helpful.
I need to allow comments on only one category, the blog. I use categories to run a lot of other aspects of my site but only want people to comment on the blog. It looks like I will use something similar to this post. I havent been able to sort it out yet. Thoughts?
Genesis has an option built in for this already. Just go to Theme Settings and set your preferences for comments.