Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialPavle Lucic
10,801 Pointswp_title vs the_title
What is the difference?
I have notice wp_title shows nothing, while the_title shows the name of the page?
1 Answer
Mathieu HAYS
9,623 Pointswp_title is meant to be used in your title tag in the head section.
By default it won't display anything on the homepage. Some plugin or even you can change its behaviour by using a filter. (plugin like Yoast SEO or WordPress SEO optimise its value).
the_title is meant to be used in the loop. It refers to the title of your page or blog post. It's meant to be used in h1, h2 etc...
Hope that makes sense
https://codex.wordpress.org/Function_Reference/wp_title https://codex.wordpress.org/Function_Reference/the_title
Pavle Lucic
10,801 PointsPavle Lucic
10,801 PointsYes, it makes.
So wp_title by itself have no meaning without Seo plugins?
Mathieu HAYS
9,623 PointsMathieu HAYS
9,623 PointsIt does have a meaning. You have to use it inside the title tag in the head.
For example a quick and easy solution would be to have the following:
<title>Your blog name ยป <?php wp_title() ?></title>
but if you want to add a SEO plugin afterward it's going to be a bit weird so you might want to do the following instead:
<title><?php wp_title() ?></title>
then in functions.php (example taken from the doc) :