WordPress.org

Ready to get started?Download WordPress

Forums

Function to find current page name (4 posts)

  1. nosmalldreams
    Member
    Posted 3 years ago #

    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!

  2. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

    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.

  3. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    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

  4. nosmalldreams
    Member
    Posted 3 years ago #

    the_title() did it for me. Many thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic