Aleš Sýkora / August 29, 2019 / 3 comments
Remove Archive Title Prefix in Astra Theme
1 min read / WordPress / Share on: Twitter, LinkedIn, Facebook
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. 🍻
Zee
This didn’t work for me. I pasted the code in the function.php file and no luck. I copied the entire thing and the ‘Archive’ prefix still appears on the custom post type archive page/
Memo
Thank you! This worked perfectly
Aleš Sýkora
Hello! Are you using the Astra theme? I dont work with it anymore. Please try this instead Remove Archive Title prefix in WordPress.