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:
- PHP code in a custom function with conditional tag
- PHP code for a remove_action directly in any CPT template file
- 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.
Was This Tutorial Helpful?