WordPress

Remove Category And Archive Title

In this topic, We are going to see that How to Remove Category and Archive Title.

First of all, you need to create a post with a Category and Tag.

You can see the below images,






To remove Category and Archive Title just add the below code in your functions.php file.

<?php 
function prefix_category( $title ) {
    if ( is_category() ) {
        $title = single_cat_title( '', false );
    }elseif( is_tag() ){
      $title = single_cat_title( '', false );
    }elseif( is_author() ){
      $title = get_the_author();
    }elseif (is_date()) {
       $title = get_the_date('M Y');
    }elseif (is_post_type_archive()) {  //for custom post types
      $title = post_type_archive_title( '' ,false); 
    }
    return $title;
}
add_filter( 'get_the_archive_title', 'prefix_category' );
?>

After adding the above code you can see Category, Tages, and Admin Title are removed.
Please check the below images,





 

If your WordPress theme has not archive.php so first of all, you need to create an archive.php.
Follow the below step to creating archive.php.

Step-1: Create an archive.php page in your themes.

Step-2: Add the below code in your archive.php.

<?php
get_header();
?>
<header class="page-header alignwide">
  <?php the_archive_title( '<h1 class="page-title">', '</h1>' ); ?>
</header>
  <?php
if ( have_posts() ) :
 $i = 0;?>
  <?php
  while ( have_posts() ) : the_post();
    $i++;
    if ( $i > 1 ) {
      echo '<hr class="post-separator styled-separator is-style-wide section-inner" aria-hidden="true" />';
    } ?>
    <article class="post=<?php the_ID();?>">
      <header class="entry-header has-text-align-center<?php echo esc_attr( $entry_header_classes ); ?>">

        <div class="entry-header-inner section-inner medium">

          <?php
          /**
           * Allow child themes and plugins to filter the display of the categories in the entry header.
           *
           * @since Twenty Twenty 1.0
           *
           * @param bool   Whether to show the categories in header, Default true.
           */          $show_categories = apply_filters( 'twentytwenty_show_categories_in_entry_header', true );

          if ( true === $show_categories && has_category() ) {
            ?>

            <div class="entry-categories">
              <span class="screen-reader-text"><?php _e( 'Categories', 'twentytwenty' ); ?></span>
              <div class="entry-categories-inner">
                <?php the_category( ' ' ); ?>
              </div><!-- .entry-categories-inner -->
            </div><!-- .entry-categories -->

            <?php
          }

          if ( is_singular() ) {
            the_title( '<h1 class="entry-title">', '</h1>' );
          } else {
            the_title( '<h2 class="entry-title heading-size-1"><a href="' . esc_url( get_permalink() ) . '">', '</a></h2>' );
          }

          $intro_text_width = '';

          if ( is_singular() ) {
            $intro_text_width = ' small';
          } else {
            $intro_text_width = ' thin';
          }

          if ( has_excerpt() && is_singular() ) {
            ?>

            <div class="intro-text section-inner max-percentage<?php echo $intro_text_width; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- static output ?>">
              <?php the_excerpt(); ?>
            </div>

            <?php
          }

          // Default to displaying the post meta.
          twentytwenty_the_post_meta( get_the_ID(), 'single-top' );
          ?>

        </div><!-- .entry-header-inner -->

      </header><!-- .entry-header -->

      <div class="post-inner <?php echo is_page_template( 'templates/template-full-width.php' ) ? '' : 'thin'; ?> ">

        <div class="entry-content">

          <?php
          if ( is_search() || ! is_singular() && 'summary' === get_theme_mod( 'blog_content', 'full' ) ) {
            the_excerpt();
          } else {
            the_content( __( 'Continue reading', 'twentytwenty' ) );
          }
          ?>

        </div><!-- .entry-content -->

      </div><!-- .post-inner -->

      <div class="section-inner">
        <?php
        wp_link_pages(
          array(
            'before'      => '<nav class="post-nav-links bg-light-background" aria-label="' . esc_attr__( 'Page', 'twentytwenty' ) . '"><span class="label">' . __( 'Pages:', 'twentytwenty' ) . '</span>',
            'after'       => '</nav>',
            'link_before' => '<span class="page-number">',
            'link_after'  => '</span>',
          )
        );

        edit_post_link();

        // Single bottom post meta.
        twentytwenty_the_post_meta( get_the_ID(), 'single-bottom' );

        if ( post_type_supports( get_post_type( get_the_ID() ), 'author' ) && is_single() ) {

          get_template_part( 'template-parts/entry-author-bio' );

        }
        ?>

      </div><!-- .section-inner -->
    </article><!-- .article-->
<?php endwhile;
else :
  echo '<p>There are no posts!</p>';
endif;

get_template_part( 'template-parts/footer-menus-widgets' ); 

get_footer();
?>

Thank you, I hope you guys found something useful.

Mitali Kukadiya

I am a Junior WordPress Developer at Vision Infotech. I have good skills in WordPress, PHP, HTML, CSS, and jQuery.

Share
Published by
Mitali Kukadiya

Recent Posts

Testing hk

Testing

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

Operation

Testing

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

TETS NEW

test

3 years ago