Passer la navigation

[Résolu] Remove wording "Archives: " from custom post archive page

This support ticket is created Il y a 3 years, 6 months. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Fuseau horaire du supporter : Asia/Karachi (GMT+05:00)

Ce sujet contient 1 reply, a 2 voix.

Dernière mise à jour par Waqar Il y a 3 years, 6 months.

Assisté par: Waqar.

Auteur
Publications
#2287585
Screenshot 2022-02-09 at 5.15.17 PM.png

Dear Sir/Madam,

Please refer to page lien caché, I want to remove the wording "Archives: ", this is the Archives page for a Toolset custom post, please advise how I can remove it but keep existing post listing format.

Best regards,

Kelvin

#2287759

Hi Kelvin,

Thank you for contacting us and I'd be happy to assist.

That text is included by WordPress before the archive titles. by default.

You'll need to use the filter "get_the_archive_title" to remove this text and an example snippet can be found at:
https://developer.wordpress.org/reference/functions/get_the_archive_title/#user-contributed-notes


function my_theme_archive_title( $title ) {
    if ( is_category() ) {
        $title = single_cat_title( '', false );
    } elseif ( is_tag() ) {
        $title = single_tag_title( '', false );
    } elseif ( is_author() ) {
        $title = '<span class="vcard">' . get_the_author() . '</span>';
    } elseif ( is_post_type_archive() ) {
        $title = post_type_archive_title( '', false );
    } elseif ( is_tax() ) {
        $title = single_term_title( '', false );
    }
  
    return $title;
}
 
add_filter( 'get_the_archive_title', 'my_theme_archive_title' );

The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.

regards,
Waqar