Archived topic
Global setting to exclude featured image and content title
7 replies · Started by Piccia on August 23, 2017
Hi there, I'm migrating my own site from an evil super-bloat theme to the amazing GP. So that I don't have to trail through hundreds of posts, free image downloads and pages and turn things off manually on each item, I need a way to exclude content titles and featured images globally. I might not want to do it to absolutely every post type though.
Thank you in advance!
Piccia
Hi Piccia,
Do you know the specific post types you want to target or exclude?
I want to target blog posts, for sure, and Easy digital download posts. Do you need to know more?
For the title, do this:
add_action( 'after_setup_theme', 'tu_add_filters' );
function tu_add_filters() {
add_filter( 'generate_show_title', 'tu_cpt_remove_title' );
}
function tu_cpt_remove_title( $title ) {
if ( 'post' == get_post_type() || 'download' == get_post_type() ) {
return false;
}
return $title;
}
Adding PHP: https://docs.generatepress.com/article/adding-php/
As for the featured image, it's probably best to use some CSS:
.single-post .page-header-image-single,
.single-download .page-header-image-single {
display: none;
}
Adding CSS: https://docs.generatepress.com/article/adding-css/
Hi Tom, thank you so much for this!
However, the PHP for taking the title out isn't working. Could it be because I am using a Toolset CPT for my blog posts?
Thank you in advance
p.s. I don't get the email notification for your replies. Sorry for not thanking you earlier!
No problem! Can you try the updated PHP above?
I will, although in the meantime I have fully comprehended the stellar awesomeness of new page headers as well as sections so that's now probably redundant. I think simply ditching my old Toolset post layout is the way forward. I cannot thank you enough for such an amazing theme!
That's awesome, really glad you're enjoying it! :)