Site logo

Archived topic

Hide title on custom post type

5 replies · Started by Laurentiu on December 26, 2022

Viewing posts 1–6 of 6

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.

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?

This archived topic is closed to new replies.