WP Smith

Creating WordPress & Genesis Websites Since 2010

  • Home
  • About
  • Services
  • Blog
  • Contact

Nov 29 2011

Conditionally Remove Post Meta in Genesis

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]

Written by Travis Smith · Categorized: Genesis

StudioPress Premium WordPress Themes     WP Engine Managed WordPress Hosting

What can I do for you!?

Custom Development

We develop plugins by determining both business/functional and technical requirements, following WordPress development best practices, and using agile methodology to ensure you get the best solution.

Consulting

Have questions? Need a reliable developer to consult? Please contact us today!

Customized Theme

We can customize your theme or child theme, or create a child theme for you based on your needs while enhancing the performance of every individual attribute.

Customized Plugin

We can customize your plugins, extend plugins (e.g., Gravity Forms, Jetpack, Soliloquy) based on your needs ensuring security, performance, and positive business impact.

Contact Us

About Travis Smith

As a WordPress enthusiast, developer, and speaker, Travis writes about what he learns in WordPress trying to help other WordPress travelers, beginners and enthusiasts with tutorials, explanations, & demonstrations.

Comments

  1. bMiller says

    January 16, 2012 at 4:03 pm

    Thanks for the code. Do you know how to remove the “post_meta” on the search results page JUST for pages?

    Reply
    • Travis Smith says

      January 30, 2012 at 11:02 am

      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]

      Reply
  2. Tracy says

    May 8, 2012 at 9:04 pm

    Thanks for this post! Very helpful.

    Reply
  3. justin says

    October 18, 2012 at 7:58 pm

    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?

    Reply
    • Travis Smith says

      November 2, 2012 at 1:33 am

      Genesis has an option built in for this already. Just go to Theme Settings and set your preferences for comments.

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • Twitter
  • Facebook
  • LinkedIn
  • Google+
  • RSS

Copyright © 2025 � WP Smith on Genesis on Genesis Framework � WordPress � Log in