Archived topic
Hide title on custom post type
5 replies · Started by Laurentiu on December 26, 2022
I'm trying to hide the title of a custom post type and it is not working. I used the code below, found on this forum:
add_action( 'wp', 'tu_disable_cpt_elements' );
function tu_disable_cpt_elements() {
if ( 'airfields' === get_post_type() && is_singular() ) {
add_filter( 'generate_show_title', '__return_false' );
}
}
The if is being executed, I added a text after it and it was displayed, but the filter doesn't seem to be working.
Hi there,
Can you try using creating a Layout Element to disable the content title first?
https://docs.generatepress.com/article/layout-element-overview/#disable-element
The CPT should show in the Display Rules:
https://docs.generatepress.com/article/layout-element-overview/#display-rules
I did it, but the title is still displayed. I tested deactivating other things, like the header, and it works for other elements but not the title.
What is strange is that I disable the title from the edit page, and it still shows up.
Can you link us to the page in question?
Sure, here it is.
