WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] get parent pages name in string format (3 posts)

  1. pybiru
    Member
    Posted 1 year ago #

    Hi,

    I have a custom post_type(using magic fields2) called "towns". Town "x" has subpages, when I am on these subpages I need to get the string name of the parent page("x") and not the ID. I've tried...

    echo $post->post_parent(returns ID)
    
    $parent_title = get_the_title($page->post_parent);
    				echo $parent_title; (returns sub-page/ current page name)
  2. keesiemeijer
    moderator
    Posted 1 year ago #

    Try it with this:

    $parent_page = get_the_title($post->post_parent);
    echo 'parent page = ' . $parent_page;
  3. pybiru
    Member
    Posted 1 year ago #

    Thanks a million keesiemeijer. Works great.

Topic Closed

This topic has been closed to new replies.

About this Topic