Support » Themes and Templates » Function to find current page name

  • nosmalldreams

    (@nosmalldreams)


    I’m trying to build a theme from scratch. When I navigate to a page (not a category – a page), then I want to display the name of the current page on the screen. The get_page method (http://codex.wordpress.org/Function_Reference/get_page) seems to require the id of the current page, but I don’t know how to find out that id. Advice?

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Emil Uzelac

    (@emiluzelac)


    Theme Review Admin


    Go to WP Dasboard, click on Pages > Edit Pages. Now after that you’ll see the list of all pages you have on your site. Just mouseover the title and you’ll see the page ID.

    Example for default About page the ID will look something like this:
    /wp-admin/post.php?post=2&action=edit

    The number 2 after the post= is the page ID number.

    Michael

    (@alchymyth)


    Forum Moderator


    When I navigate to a page (not a category – a page), then I want to display the name of the current page on the screen.

    depends on where you want to show the page title, but still give the_title() a try;
    you should be able to get the page id with $post->ID

    nosmalldreams

    (@nosmalldreams)


    the_title() did it for me. Many thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Function to find current page name’ is closed to new replies.