Question

This the url format: www.mysite.com/pageone

How do I get the page name? what is the wordpress function/method for this?

bloginfo('name') return the site name. I want the function that returns (return not echo) the name of the current page.

Was it helpful?

Solution

To display title of current page you use the_title() template tag.

Related and slightly more specific functions are:

  • get_the_title() that returns title without echoing and can retrieve title of another page/post, given its ID as input;
  • the_title_attribute() that returns a little more cleaned up version (safer to use in link titles without breaking markup and such) and takes arguments in query string format.
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top