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


Comments

6 responses to “How to remove post info from custom post type only in Genesis”

  1. […] How to remove post info from custom post type only in Genesis […]

  2. Simon Barnett Avatar
    Simon Barnett

    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

    1. Brad Dalton Avatar
      Brad Dalton

      Why did you create the custom loop for your CPT?

      1. Simon Barnett Avatar
        Simon Barnett

        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?

        1. Brad Dalton Avatar
          Brad Dalton

          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.

          1. Simon Barnett Avatar
            Simon Barnett

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

Leave a Reply

Join 5000+ Followers

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