![]() ![]() So how do we fetch the page title for our posts page? If you try to use this function for the page title outside the loop, all you get is the title of the first post on the page. Problem is, you are using that inside the loop to display the title for all of your blog entries on the page and that won’t do you any good when trying to fetch the page title outside the loop. WordPress provides you with the function the_title(), which works great inside the loop. ![]() Rather than leaving it up to the user to go in and try to hack your theme to get the page title to appear, you decide you want to display this page title for them automatically. As an example, it could be that I am using the posts page for displaying news items and want to label my posts page ‘News’. This helps add clarity for users and makes all of my pages have a more consistent appearance. So now that my posts page is no longer the front page, I want to display the page title that the user assigned to that page in my theme. So in the example above, I want to set a static page as my homepage and delegate another page to host my blog (aka posts page). As you probably are already aware, a user can go to ‘Settings’ -> ‘Reading’ in the WordPress admin menu and change what pages are used for the front page and the posts page (aka blog page)… ![]() It is important that your theme displays the proper title on the page no matter what settings a user has on their site. This little tidbit is for all you WordPress themers out there. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |