What if I want to display a page's title in the header.php template?
Extra points if I can overwrite the title in the page template file, because what might work in content-single.php might not work in category.php or page.php or frontpage.php
What if I want to display a page's title in the header.php template?
Extra points if I can overwrite the title in the page template file, because what might work in content-single.php might not work in category.php or page.php or frontpage.php
<?php echo get_the_title(); ?> will display the current page's title.
Can anyone go for the bonus points? Because on my category pages, that displays the first post in that category when I'd like the title to be the category.
I suppose I can drop a big series of "if" statements into the header like
if ( is_singular() )
get_the_title()
else if ( is_category() )
single_cat_title( '', true )
else if ( is_front_page() )
...
But it seems inelegant.
Oh, right I hadn't thought to look in the <title> tag further up in the header. That gives me wp_title(''); and other stuff to work with.
You must log in to post.