Last active
November 26, 2016 17:08
-
-
Save filipvanreeth/a48a52d3f59494f609fd45a6cddfa476 to your computer and use it in GitHub Desktop.
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
function wb_get_title( $before = '<h1>', $after = '</h1>' ) { | |
$title = NULL; | |
if ( is_page() || is_singular() || is_single() ) { | |
$title = get_the_title(); | |
} elseif ( is_archive() ) { | |
$title = $category_name = single_cat_title( '', false ); | |
} elseif ( is_post_type_archive() ) { | |
$obj = get_queried_object(); | |
$title = $obj->labels->name; | |
} elseif ( is_tax() ) { | |
$title = $wp_query->obj->name; | |
} else { | |
$title = get_the_title(); | |
} | |
if ( $title ) { | |
echo $before . $title . $after; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment