Created
January 15, 2014 17:38
-
-
Save ejntaylor/8440704 to your computer and use it in GitHub Desktop.
Remove Archive from Title
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Remove Archive from Title | |
| function woo_archive_title ( $before = '', $after = '', $echo = true ) { | |
| global $wp_query; | |
| if ( is_category() || is_tag() || is_tax() ) { | |
| $taxonomy_obj = $wp_query->get_queried_object(); | |
| $term_id = $taxonomy_obj->term_id; | |
| $taxonomy_short_name = $taxonomy_obj->taxonomy; | |
| $taxonomy_raw_obj = get_taxonomy( $taxonomy_short_name ); | |
| } // End IF Statement | |
| $title = ''; | |
| $delimiter = ' | '; | |
| $date_format = get_option( 'date_format' ); | |
| // Category Archive | |
| if ( is_category() ) { | |
| $title = '<span class="fl cat">' . single_cat_title( '', false ) . '</span> <span class="fr catrss">'; | |
| $cat_obj = $wp_query->get_queried_object(); | |
| $cat_id = $cat_obj->cat_ID; | |
| $title .= '<a href="' . get_term_feed_link( $term_id, $taxonomy_short_name, '' ) . '">' . __( 'RSS feed for this section','woothemes' ) . '</a></span>'; | |
| $has_title = true; | |
| } | |
| // Day Archive | |
| if ( is_day() ) { | |
| $title = __( 'Archive', 'woothemes' ) . $delimiter . get_the_time( $date_format ); | |
| } | |
| // Month Archive | |
| if ( is_month() ) { | |
| $date_format = apply_filters( 'woo_archive_title_date_format', 'F, Y' ); | |
| $title = __( 'Archive', 'woothemes' ) . $delimiter . get_the_time( $date_format ); | |
| } | |
| // Year Archive | |
| if ( is_year() ) { | |
| $date_format = apply_filters( 'woo_archive_title_date_format', 'Y' ); | |
| $title = __( 'Archive', 'woothemes' ) . $delimiter . get_the_time( $date_format ); | |
| } | |
| // Author Archive | |
| if ( is_author() ) { | |
| $title = __( 'Author Archive', 'woothemes' ) . $delimiter . get_the_author_meta( 'display_name', get_query_var( 'author' ) ); | |
| } | |
| // Tag Archive | |
| if ( is_tag() ) { | |
| $title = __( 'Tag Archives', 'woothemes' ) . $delimiter . single_tag_title( '', false ); | |
| } | |
| // Post Type Archive | |
| if ( function_exists( 'is_post_type_archive' ) && is_post_type_archive() ) { | |
| /* Get the post type object. */ | |
| $post_type_object = get_post_type_object( get_query_var( 'post_type' ) ); | |
| $title = $post_type_object->labels->name . ' ' . __( 'Archive', 'woothemes' ); | |
| } | |
| // Post Format Archive | |
| if ( get_query_var( 'taxonomy' ) == 'post_format' ) { | |
| $post_format = str_replace( 'post-format-', '', get_query_var( 'post_format' ) ); | |
| $title = get_post_format_string( $post_format ) . ' ' . __( ' Archives', 'woothemes' ); | |
| } | |
| // General Taxonomy Archive | |
| if ( is_tax() ) { | |
| $title = sprintf( __( '%1$s Archives: %2$s', 'woothemes' ), $taxonomy_raw_obj->labels->name, $taxonomy_obj->name ); | |
| } | |
| if ( strlen($title) == 0 ) | |
| return; | |
| $title = $before . $title . $after; | |
| // Allow for external filters to manipulate the title value. | |
| $title = apply_filters( 'woo_archive_title', $title, $before, $after ); | |
| if ( $echo ) | |
| echo $title; | |
| else | |
| return $title; | |
| } // End woo_archive_title() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment