[NSFW] Change Web Stories Archive Page Title
-
Hi everyone!
Web Stories plugin automatically generates “Archives: Stories” title in archive page. To fix this issue and remove the word “Archives:” you can just add the filter in functions.php of your particular theme. The result will be a title with only the word “Stories”//remove unnecessary words from any standard title add_filter( 'get_the_archive_title', function ($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_tax() ) { //for custom post types $title = sprintf( __( '%1$s' ), single_term_title( '', false ) ); } elseif (is_post_type_archive()) { $title = post_type_archive_title( '', false ); } return $title; });
But if you want to customize the title, adding other words, better create the custom template of archive.php page of your wordpress theme.
In my case, I created the additional page called archive-web-story.php by copying all the code from the original archive.phpFor this purpose another filter has been added in the functions.php
function archive_web_story_template( $template, $template_type, $post ) { if ( ! is_singular() && 'web-story' === get_post_type() && ! is_post_type_archive( 'web-story' ) ) { $template = get_theme_file_path( 'archive-web-story.php' ); } return $template; } add_filter( 'single_template', 'archive_web_story_template', 10, 3 );
Then in archive-web-story.php page I replaced the original <h1> tag with the modified one:
<h1><?php _e('Web', 'text-domain-name'); ?> <?php the_archive_title( '', '' );?></h1>
Here you can see the example of my website.
Warning: only for users with advanced knowledge in wordpress code programming. Before making modifications it is important to create backup files!
- The topic ‘[NSFW] Change Web Stories Archive Page Title’ is closed to new replies.