Site logo

Archived topic

Removing title on custom post type

10 replies · Started by njwrigley on March 10, 2017

Viewing posts 1–11 of 11

Hi there,

I have a Custom Post Type with a slug of "gig".

I'm just wondering what the best way is to remove the display of the post title on the single post page in GP?

I don't want to use a CSS hack 'display:none' and wondered if you had any better ideas?

Thanks

I should perhaps add that I'm playing with Beaver Themer, and so I don't want to edit a single.php file as Beaver Themer is taking care of the display for me.

The generate_show_title is the filter you're looking for: https://docs.generatepress.com/article/generate_show_title/

You could try:

add_filter( 'generate_show_title','tu_gig_remove_title' );
function tu_gig_remove_title( $title ) {
    if ( is_singular( 'gig' ) ) {
        return false;
    }

    return $title;
}

Yep - that worked a treat!

Thanks Tom.

You're welcome :)

Tom,

I am trying to do the same here:

add_filter( 'generate_show_title','bb_remove_title' );
function bb_remove_title( $title ) {
    if ( is_singular( array( 'refurbs', 'yizumi' ) ) ) {
        return false;
    }

    return $title;
}

This isn't working for me though. Any ideas?

Looks good to me. Are you sure refurbs/yizumi are the correct slugs of your custom post types?

This function would also on affect the single posts of those custom post types, not the listing/archives page.

This should do it:

function bb_remove_title( $title ) {
    if ( is_singular( array( 'refurbs', 'yizumi' ) ) ) {
        return false;
    }

    return $title;
}

add_action( 'after_setup_theme','tu_after_setup_theme' );
function tu_after_setup_theme() {
    add_filter( 'generate_show_title', 'bb_remove_title' );
}

It's working, thanks Tom !

You're welcome :)

This archived topic is closed to new replies.