Aleš Sýkora / August 29, 2019 / 3 comments

Remove Archive Title Prefix in Astra Theme

Post summary: You can use this as a plugin to disable the Archive: Category: Tag: prefix in Astra Theme archives.

You can use this as a plugin to disable the Archive: Category: Tag: prefix in Astra Theme archives.

<?php
/**
 * Plugin Name: Remove Archive Text from the Archive Title.
 * Description: Removes the text "Archive" from funnction get_the_archive_title() of WordPress
 * Plugin URI: https://www.alessykora.cz/
 * Author: Aleš Sýkora
 * Author URI: https://www.alessykora.cz/
 * Version: 1.0.1
 * License: GPL2 or later
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 */

defined( 'ABSPATH' ) or exit;

add_filter( 'get_the_archive_title', 'astra_archive_title_remove_prefix_text' );

/**
 * Remove Prefix : from Archive title
 *
 * @param  string $title Default title.
 * @return string $title updated title.
 */
function astra_archive_title_remove_prefix_text( $title ) {

	if ( is_post_type_archive() ) {
        $title = post_type_archive_title( '', false );
    } elseif ( is_tax() ) {
    	$tax = get_taxonomy( get_queried_object()->taxonomy );
    	$title = single_term_title( '', false );
    } elseif ( is_category ()) {
		$title = single_cat_title( '', false);
	}

	return $title;
}

I you want to completely disable the Archive title box, use this:

// REMOVE ASTRA ARCHIVE HEADER
remove_action( 'astra_archive_header', 'astra_archive_page_info' );

Fuel my passion for writing with a beer🍺

Your support not only makes me drunk but also greatly motivates me to continue creating content that helps. Cheers to more discoveries and shared success. 🍻

3 comments

Share Your Thoughts