[Resolved] Removing title on custom post type

Home Forums Support [Resolved] Removing title on custom post type

Home Forums Support Removing title on custom post type

  • This topic has 10 replies, 4 voices, and was last updated 7 years ago by Tom.
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #289751
    njwrigley

    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

    #289758
    njwrigley

    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.

    #289820
    Tom
    Lead Developer
    Lead Developer

    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;
    }
    #290395
    njwrigley

    Yep – that worked a treat!

    Thanks Tom.

    #290399
    Tom
    Lead Developer
    Lead Developer

    You’re welcome ๐Ÿ™‚

    #297959
    Richard Bland

    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?

    #298008
    Tom
    Lead Developer
    Lead Developer

    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.

    #299553
    Jamal

    Hi Tom

    Struggling with this as well and then i found this answer https://generatepress.com/forums/topic/show-title-filter-is-not-applied/#post-259752

    How can i combine the above with this? Thanks !

    #299623
    Tom
    Lead Developer
    Lead Developer

    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' );
    }
    #299797
    Jamal

    It’s working, thanks Tom !

    #299952
    Tom
    Lead Developer
    Lead Developer

    You’re welcome ๐Ÿ™‚

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.