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.

  • I am not sure what you want to get from what input. Page's title from page's URL? Page slug from something? Please write it out more clearly. – Rarst Jan 18 '11 at 9:12
  • @Rarst: I clarified my question now – Zebra Jan 18 '11 at 9:16

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.
| improve this answer | |
  • Or maybe even get_query_var('pagename')? – t31os Jan 18 '11 at 16:34
  • @t31os if I am not mistaken that would be slug and not title. – Rarst Jan 18 '11 at 16:59
  • Oh yes of course, my bad... – t31os Jan 18 '11 at 18:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.