0

I have the Shaped Blog theme and I try to remove "Browse Category:" from my Archive title.

I look in the code and found in "template-tags.php" this code :

` ////////////////////////////////////////////////////////////////// // Archive title //////////////////////////////////////////////////////////////////

if ( ! function_exists( 'shaped_blog_archive_title' ) ) :

function shaped_blog_archive_title( $before = '', $after = '' ) {
    if ( is_category() ) {
        $title = sprintf( __( 'Browse Category: %s', 'shaped-blog' ), single_cat_title( '', false ) );
    } elseif ( is_tag() ) {
        $title = sprintf( __( 'Browse Tag: %s', 'shaped-blog' ), single_tag_title( '', false ) );
    } elseif ( is_author() ) {
        $title = sprintf( __( 'Browse Author: %s', 'shaped-blog' ), '<span class="vcard">' . get_the_author() . '</span>' );
    } elseif ( is_year() ) {
        $title = sprintf( __( 'Browse Year: %s', 'shaped-blog' ), get_the_date( _x( 'Y', 'yearly archives date format', 'shaped-blog' ) ) );
    } elseif ( is_month() ) {
        $title = sprintf( __( 'Browse Month: %s', 'shaped-blog' ), get_the_date( _x( 'F Y', 'monthly archives date format', 'shaped-blog' ) ) );
    } elseif ( is_day() ) {
        $title = sprintf( __( 'Browse Day: %s', 'shaped-blog' ), get_the_date( _x( 'F j, Y', 'daily archives date format', 'shaped-blog' ) ) );
    } elseif ( is_tax( 'post_format' ) ) {
        if ( is_tax( 'post_format', 'post-format-aside' ) ) {
            $title = _x( 'Asides', 'post format archive title', 'shaped-blog' );
        } elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) {
            $title = _x( 'Galleries', 'post format archive title', 'shaped-blog' );
        } elseif ( is_tax( 'post_format', 'post-format-image' ) ) {
            $title = _x( 'Images', 'post format archive title', 'shaped-blog' );
        } elseif ( is_tax( 'post_format', 'post-format-video' ) ) {
            $title = _x( 'Videos', 'post format archive title', 'shaped-blog' );
        } elseif ( is_tax( 'post_format', 'post-format-quote' ) ) {
            $title = _x( 'Quotes', 'post format archive title', 'shaped-blog' );
        } elseif ( is_tax( 'post_format', 'post-format-link' ) ) {
            $title = _x( 'Links', 'post format archive title', 'shaped-blog' );
        } elseif ( is_tax( 'post_format', 'post-format-status' ) ) {
            $title = _x( 'Statuses', 'post format archive title', 'shaped-blog' );
        } elseif ( is_tax( 'post_format', 'post-format-audio' ) ) {
            $title = _x( 'Audio', 'post format archive title', 'shaped-blog' );
        } elseif ( is_tax( 'post_format', 'post-format-chat' ) ) {
            $title = _x( 'Chats', 'post format archive title', 'shaped-blog' );
        }
    } elseif ( is_post_type_archive() ) {
        $title = sprintf( __( 'Browse Archives: %s', 'shaped-blog' ), post_type_archive_title( '', false ) );
    } elseif ( is_tax() ) {
        $tax = get_taxonomy( get_queried_object()->taxonomy );
        /* translators: 1: Taxonomy singular name, 2: Current taxonomy term */
        $title = sprintf( __( '%1$s: %2$s', 'shaped-blog' ), $tax->labels->singular_name, single_term_title( '', false ) );
    } else {
        $title = __( 'Archives', 'shaped-blog' );
    }

    /**
     * Filter the archive title.
     *
     * @param string $title Archive title to be displayed.
     */
    $title = apply_filters( 'get_the_archive_title', $title );

    if ( ! empty( $title ) ) {
        echo $before . $title . $after;
    }
}
endif;

`

I don't understand how to remove it despite the little explanation at the end.

Thanks you for your help :)

1 Answer 1

0

If you are using child theme. Add filter in the functions.php of child theme like this.

add_filter('get_the_archive_title','wpse_224884_filter_archive_title',10,1);
function wpse_224884_filter_archive_title($title){
   if ( is_category() ) {
      $title = sprintf( __( '%s', 'shaped-blog' ), single_cat_title( '', false ) );
   } 
   return $title;
}

Or

Copy the entire function into functions.php

function shaped_blog_archive_title( $before = '', $after = '' ) {
    if ( is_category() ) {
    $title = sprintf( __( '%s', 'shaped-blog' ), single_cat_title( '', false ) );
  }else if ....//remaining code
}

without if ( ! function_exists( 'shaped_blog_archive_title' ) ) :

The only change you need to do is remove Browse Category: in line 4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.