I'm using Elementor Pro to build my page templates, and I have changed the tags labels to 'topics' using the functions below – this works everywhere except in the Elementor Archive Title widget (which is made through a regular Title widget with the dynamic tag set to 'Archive Title').
Here are my functions to change tags to topics:
// Change tags to topics
function wd_hierarchical_tags_register() {
// Maintain the built-in rewrite functionality of WordPress tags
global $wp_rewrite;
$rewrite = array(
'hierarchical' => false, // Maintains tag permalink structure
'slug' => get_option('tag_base') ? get_option('tag_base') : 'tag',
'with_front' => ! get_option('tag_base') || $wp_rewrite->using_index_permalinks(),
'ep_mask' => EP_TAGS,
);
// Redefine tag labels (or leave them the same)
$labels = array(
'name' => _x( 'Topics', 'Taxonomy General Name', 'hierarchical_tags' ),
'singular_name' => _x( 'Topic', 'Taxonomy Singular Name', 'hierarchical_tags' ),
'menu_name' => __( 'Topics', 'hierarchical_tags' ),
'all_items' => __( 'All Topics', 'hierarchical_tags' ),
'parent_item' => __( 'Parent Topic', 'hierarchical_tags' ),
'parent_item_colon' => __( 'Parent Topic:', 'hierarchical_tags' ),
'new_item_name' => __( 'New Topic Name', 'hierarchical_tags' ),
'add_new_item' => __( 'Add New Topic', 'hierarchical_tags' ),
'edit_item' => __( 'Edit Topic', 'hierarchical_tags' ),
'update_item' => __( 'Update Topic', 'hierarchical_tags' ),
'view_item' => __( 'View Topic', 'hierarchical_tags' ),
'separate_items_with_commas' => __( 'Separate topics with commas', 'hierarchical_tags' ),
'add_or_remove_items' => __( 'Add or remove topics', 'hierarchical_tags' ),
'choose_from_most_used' => __( 'Choose from the most used', 'hierarchical_tags' ),
'popular_items' => __( 'Popular Topics', 'hierarchical_tags' ),
'search_items' => __( 'Search Topics', 'hierarchical_tags' ),
'not_found' => __( 'Not Found', 'hierarchical_tags' ),
);
// Override structure of built-in WordPress tags
register_taxonomy( 'post_tag', 'post', array(
'hierarchical' => true, // Was false, now set to true
'query_var' => 'tag',
'labels' => $labels,
'rewrite' => $rewrite,
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'_builtin' => true,
) );
}
add_action('init', 'wd_hierarchical_tags_register');
Despite the above code, I'm still seeing 'Tags' as a prefix on archive pages. I've also tried removing the prefix from archive titles, but this also has no effect on the Elementor title widget.
// Remove default labels from archive title
add_filter( 'get_the_archive_title', function ($title) {
if ( is_category() ) {
$title = single_cat_title( '', false );
} elseif ( is_tag() ) {
$title = single_topic_title( '', false );
} elseif ( is_author() ) {
$title = '<span class="vcard">' . get_the_author() . '</span>' ;
}
return $title;
});
Any help would be appreciated. I'd be happy if I can either change tags to topics on archive titles, or completely remove the 'tags:' prefix from archive titles (I'd be fine with removing author/category/month/year too).