X
X
xlo2402021-06-24 17:42:17
WordPress
xlo240, 2021-06-24 17:42:17

How to remove the word Archive from the title tag?

Made a list of posttypes in the file archive-statyi.php
The title tag displays the phrase "Article Archive".
How to remove the word Archive?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Artem Zolin, 2021-06-24
@artzolin

// удаляем "Рубрика: ", "Метка: " и т.д. из заголовка архива
add_filter( 'get_the_archive_title', function( $title ){
  return preg_replace('~^[^:]+: ~', '', $title );
});

A
Anton Litvinenko, 2021-06-24
@AntonLitvinenko

here is another option for a change, but the first one and I like it more

function x_theme__remove_name_cat( $title ){
  if ( is_category() ) {
    $title = single_cat_title( '', false );
  } elseif ( is_tag() ) {
    $title = single_tag_title( '', false );
  }
  return $title;
}
add_filter( 'get_the_archive_title', 'x_theme__remove_name_cat' );

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question