Best way Show title of all types of pages in wordpress

0.77K views
no comments
11 Apr 2015 5:34 pm

Mostly #wordpress theme developers put header data information in header.php file of theme and they not use each different header file for each wordpress post or pages category and this is best dynamic and quick way to put header information in header.php like head tag and #css #javascript and other sources files because if developer just create different header files then they need to a file in header or need to modify header information then they go to each of different header file change information whatever they want to and  this is time consumable thing also.

But in single header.php file we can only call a single function for header title of page but in #wordpress more function are available to show the title of page.

Here is example to show matched page title

if (is_single() || is_page()) {
	the_title();
} else if (is_front_page() || is_home()) {
	bloginfo('title');
} else if (strstr($_SERVER['REQUEST_URI'], 'author')) {
	$curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) :
		get_userdata(get_query_var('author'));

	echo $curauth->first_name;
} else {
	wp_title('', true);
}

NOTE:Your Email Address will be not shown and please do not add spamming comments because here is REL="NOFOLLOW" on your links and comments also moderated shown.
<code>Put html css or any language code under this tag</code>