Remove Genesis Post Info & Post Meta Conditionally

These code snippets enable you to remove specific links generated by shortcodes from the default post info and post meta output.

The code includes conditional tags which you can change and shortcodes which you can remove.

Please copy ALL the code from the view raw link and paste it at the end of your child themes functions.php file using a text editor like Notepad++

Post Info

This code only removes the comments link from all posts in category 1 on both the single post page and archive pages.

Post Meta

This code only removes the tagged with link from all posts in category 1 on both the single post page and archive pages.

Note: The code may NOT work if you have the Genesis Simple Edits plugin enabled as it can over ride any custom functions.


Comments

7 responses to “Remove Genesis Post Info & Post Meta Conditionally”

  1. perfect thanks Brad!

  2. Sorry code should be:

    add_filter( 'genesis_post_info', 'wpsites_remove_post_info_conditionally' );
    function wpsites_remove_post_info_conditionally($post_info) {
    if ( in_category('wiley') ) :
    $post_info = '[post_date] by [post_author_posts_link] [post_edit]';
    return $post_info;
    else:
    $post_info = '[post_date] by [post_author_posts_link] [post_comments] [post_edit]';
    return $post_info;
    endif;
    }

    1. not sure why it’s adding your info in the post info variables, seems to be happening when I try to paste in the code…

    2. Brad Dalton Avatar
      Brad Dalton

      Hi

      Should be:

      [code]
      if ( in_category(‘wiley’) ) :
      $post_info = ‘[post_edit]’;
      return $post_info;
      else:
      [/code]

  3. Hi Brad,

    I was hoping the first snippet would remove the post author name, date and ‘post a comment’ stuff (underneath the post title on single posts) only for posts in a particular category.

    In my case, my category name is ‘wiley’ so I did:
    [code]
    add_filter( ‘genesis_post_info’, ‘wpsites_remove_post_info_conditionally’ );
    function wpsites_remove_post_info_conditionally($post_info) {
    if ( in_category(‘wiley’) ) :
    $post_info = ‘[post_date] by [post_author_posts_link] [post_edit]’;
    return $post_info;
    else:
    $post_info = ‘[post_date] by [post_author_posts_link] [post_comments] [post_edit]’;
    return $post_info;
    endif;
    }
    [/code]
    Doesn’t seem to be working, wondering what I’m doing wrong…

  4. SarahBennetMills Avatar
    SarahBennetMills

    Hi Brad!

    Your tutorials are simply awesome. I have customized my Genesis website by following your tutorials. You simply rock. Thanks for helping me in Genesis customization.

    1. Brad Dalton Avatar
      Brad Dalton

      You’re welcome Sarah.

Leave a Reply

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.