Site logo

[Resolved] Remove Archive Title on Custom Post Type

Home Forums Support [Resolved] Remove Archive Title on Custom Post Type

Home Forums Support Remove Archive Title on Custom Post Type

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2534103
    Rostyslav

    Hello,

    I have created a CPT and added a design element to disable a title in Archive and Taxonomy but it doesnt work.

    How can I remove that titles. I want to create a custom layout for that Archives.

    Thanks

    https://ibb.co/Lv17md8

    #2534372
    David
    Staff
    Customer Support

    Hi there,

    try this PHP Snippet:

    add_action('wp', function(){
        if ( is_post_type_archive( 'my_custom_post_type' ) ) {
            remove_action( 'generate_archive_title', 'generate_archive_title' );
        }
    });

    change the my_custom_post_type to your CPT slug

    #2534399
    Rostyslav

    Hello!

    How can I also add the CPT taxonomies (categories in CPT) in that php?

    I also want to remove taxonomy title.

    Thanks

    #2534456
    David
    Staff
    Customer Support

    You can is the is_tax template tag:

    https://developer.wordpress.org/reference/functions/is_tax/

    eg,

    add_action('wp', function(){
        if ( is_post_type_archive( 'my_custom_post_type' ) || is_tax('my_tax_slug') ) {
            remove_action( 'generate_archive_title', 'generate_archive_title' );
        }
    });
    #2534484
    Rostyslav

    GENIUS!

    #2535361
    David
    Staff
    Customer Support

    Glad to be of help

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