WordPress.org

Support

Support » How-To and Troubleshooting » Display Page Title (NOT Post Title)

Display Page Title (NOT Post Title)

  • I have (in page.php) a section where I want to display the page title in an <h2> tag, but also its parent page, in an <h1> tag.

    How do I get the parent name to display based on whatever page it’s currently displaying?

Viewing 2 replies - 1 through 2 (of 2 total)
  • This should do what you’re asking —

    $parent_title = get_the_title($post->post_parent);
    echo $parent_title;

    To find out if a page is top-level check to see if $post->post_parent is 0.

    is there away to use this to pull the link as well ?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display Page Title (NOT Post Title)’ is closed to new replies.