• 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

How to remove post info from custom post type only in Genesis

Jill from the U.K asked this question on the StudioPress theme forums:

I have a custom post type called Products and I want to remove the post info (date and author) from this type only.

There’s different ways to remove post info from both single custom post type pages and archive custom post type pages.

The examples in this post use portfolio as the custom post type.

You can either use:

  1. PHP code in a custom function with conditional tag
  2. PHP code for a remove_action directly in any CPT template file
  3. CSS code to hide any of your post meta.

Here’s 3 examples of custom functions which include conditional tags for removing post info from single and/or archive CPT’s.

Note: you will need to remove all or some of the shortcodes within the code for the post info you don’t want to display.

Remove From Single CPT Pages

Remove From Archive CPT Pages

Remove From Archive & Single CPT Pages

Another solution is to paste a line of PHP directly into your single-portfolio.php or archive-portfolio.php file.

Remove Directly From CPT Template File

Simply past this line of code directly into any template file for your single or archive page custom post type.

remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );

Note: The above PHP code only works on sites running HTML 5 markup.

Remove Post Info Single CPT Using CSS

.single-portfolio .entry-meta {
    display: none;
}

Remove Post Info Archive CPT Using CSS

.post-type-archive-portfolio .entry-meta {
    display: none;
}

You can also use Firebug to inspect each post info link and find the specific class if you only want to remove one part of the post info using CSS code.

Most child themes built on Genesis already include PHP code which removes the post info directly from both the single and archive page templates files.

Related Tutorials

  • Remove Entry Meta From Custom Post Types in Genesis

Custom Post Type Entry Meta

Reader Interactions

Comments

  1. Simon Barnett says

    September 19, 2014 at 11:13 am

    Hi Brad,

    Many thanks for this. I got it to work via the functions.php method, but ideally I would have preferred to have it work by putting the code inside my template:
    https://gist.github.com/simbasounds/8a23c1fd588bc6583641

    In theory adding the line:
    `remove_action( ‘genesis_entry_header’, ‘genesis_post_info’, 12 );`
    to my template should have worked, but I’m clearly missing something.
    I tried the code at the top of the template, and inside my function portfolio_do_loop()

    I’ll post this query to the Genesis forum too.

    Many thanks

    Log in to Reply
    • Brad Dalton says

      September 19, 2014 at 1:22 pm

      Why did you create the custom loop for your CPT?

      Log in to Reply
      • Simon Barnett says

        September 19, 2014 at 2:53 pm

        In my earlier usage of templates my reason for custom loops was to gain much finer control over the wrapping of divs etc. Perhaps I’m misguided here: maybe I don’t need a custom loop to do that?

        So I take it that’s probably the reason a standard Genesis remove_action doesn’t work inside the template?

        Log in to Reply
        • Brad Dalton says

          September 19, 2014 at 3:13 pm

          Yes. Looks like your loop has added meta using the WordPress post meta function and my code removes the Genesis post info.

          I would use pre_get_posts to alter the loop.

          Log in to Reply
          • Simon Barnett says

            September 19, 2014 at 3:26 pm

            Thanks so much, Brad. Will give it a go..

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