BuddyDev

Search

Edit Archive page title

Tagged: 

  • Participant
    Level: Enlightened
    Posts: 88
    Torben Heikel Vinther on #21199

    Hi

    I have added a custom post type with archive enabled, but when I open the archive page the title says “Archives: Title”. How do I edit that and eg. remove the “Archives: “?

    Btw. I can’t find an archive.php file in the themes folder. Why not?

    All the best
    Torben

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #21200

    Hi Torben,
    Thank you for the question.
    Are you using community builder?

    Most of the theme(including ours) won’t add archive.php as index.php acts as a simple fallback. We only need to add archive.php if we can not use the fallback template(mostly styling/content purpose).

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 88
    Torben Heikel Vinther on #21208

    Hi Brajesh

    Yes, I’m using the Community Builder theme version 1.1.5.

    But how do I then remove the “Archives: “ before the archive title?

    Best regards
    Torben

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #21222

    Hi Torben,
    Thank you.

    Please use this code

    
    
    /**
     * Filter archive title.
     *
     * @param string $title title.
     *
     * @return string
     */
    function buddydev_custom_archive_title( $title ) {
    
    	if ( is_post_type_archive() ) {
    		$title = post_type_archive_title( '', false );
    	}
    
    	return $title;
    }
    
    add_filter( 'get_the_archive_title', 'buddydev_custom_archive_title' );
    
    

    We are using the default title generated by WordPress for archive pages. In the generated title, WordPress prepends “Archives: ” for post type archive.

    By using the code above, we change it. You can change it to anything you like.

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved