• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2785

Original Genesis & WooCommerce Tutorials & 6000+ Guaranteed Code

Snippets

  • Try Premium
  • Log in

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.

Reader Interactions

Comments

  1. atm says

    March 21, 2015 at 2:27 am

    perfect thanks Brad!

    Log in to Reply
  2. atm says

    March 20, 2015 at 8:45 pm

    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 = 'February 26, 2014 by Brad Dalton ';
    return $post_info;
    else:
    $post_info = 'February 26, 2014 by Brad Dalton 7 Comments ';
    return $post_info;
    endif;
    }

    Log in to Reply
    • atm says

      March 20, 2015 at 8:45 pm

      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…

      Log in to Reply
    • Brad Dalton says

      March 21, 2015 at 2:20 am

      Hi

      Should be:

      if ( in_category('wiley') ) :
      $post_info = '[post_edit]';
      return $post_info;
      else:
      Log in to Reply
  3. atm says

    March 20, 2015 at 8:44 pm

    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:

    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;
    }

    Doesn’t seem to be working, wondering what I’m doing wrong…

    Log in to Reply
  4. SarahBennetMills says

    February 26, 2014 at 11:24 am

    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.

    Log in to Reply
    • Brad Dalton says

      February 26, 2014 at 12:04 pm

      You’re welcome Sarah.

      Log in to Reply

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

Code written by Brad Dalton specialist for Genesis, WooCommerce & WordPress theme customization. Read More…

Advertise · WPEngine · Genesis · Log in

  • Access Problems
  • Account Details
  • Consulting
  • Tags