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 trialrosinapissaco
13,401 PointsSimple title post WP question
Hi, I can't understand the difference between:
<title><?php wp_title(); ?> </title>
<?php echo get_the_title(); ?>
I hope someone can help me. I want to show the title of the page before the article. Which one should I use?
4 Answers
rosinapissaco
13,401 PointsFixed now. I want to understand when I should use get_the_title and when to use wp_title.
Cena Mayo
55,236 Pointswp_title - "filters the text appearing in the HTML <title> tag (sometimes called the "title tag" or "meta title"), not the post, page, or category title. "
In other words, using this places text in the <title> section of your .html, which translates to what you see as a tab title in a broswer (for example, this forum post appears as "Simple title post WP question" on my browser tab.)
get_the_title simply retrieves a post title.
I'm not completely clear on your question either - where do you want the title to appear? If you can answer that, then you'll know which one is more appropriate for this particular case.
rosinapissaco
13,401 Pointsrosinapissaco
13,401 PointsI want to know when to use:
- the_title
- get_the_title
- wp_title
Edwin Goddard
8,988 PointsEdwin Goddard
8,988 PointsAre you missing something from your question?
I don't really understand it. Do you want to know what the difference between the concepts of "and" and "or"?