0

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.

2
  • 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
    Commented Jan 18, 2011 at 9:12
  • @Rarst: I clarified my question now
    – Zebra
    Commented Jan 18, 2011 at 9:16

1 Answer 1

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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