Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7850061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:43:48+00:00 2026-06-02T18:43:48+00:00

On a child page, I would like to query some custom fields of the

  • 0

On a child page, I would like to query some custom fields of the parent page as well as show all the child pages of the parent page as well? (ideally in the list of child pages, i should be able to identify which child page it is currently on)

Here’s the code I am using

<?php if($post->post_parent): 
$parent = get_post($post->post_parent);
?>
<h2><?=$parent->address;?></h2>
<? parent->get('address');?>
<?php endif; ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T18:43:49+00:00Added an answer on June 2, 2026 at 6:43 pm

    This should help get you started:

    <?php
    global $post;
    if($post->post_parent): 
    $parent = get_page($post->post_parent);
    ?>
    <h2><?php echo get_post_meta($post->post_parent, 'address', true); ?></h2>
    <?php 
    $args = array(
        'child_of'     => $post->post_parent,
        'title_li'     => '',
        'echo'         => false,
        'sort_column'  => 'menu_order, post_title',
    );
    $children = wp_list_pages($args); //RETURNS HTML OF ALL CHILD PAGES
    endif;
    ?>
    

    I’m guessing you meant to have a custom field named ‘address’ within the parent page that you could query. Otherwise, please clarify what you mean by ‘address’ (if it’s a custom meta field, a theme option, or something else).

    WARNING: The $children variable will only grab the descendants of its matching parent. NOT its top-level ancestor. That means if the current page is a grandchild, or great-grandchild, the parent page will be the child of another page.

    If you want to grab that top-level ancestor, I’ve written a function that does this recursively, but it’s pretty ugly. I would advise against going that route.

    EDIT: Use get_page(), not get_post(). Posts are not hierarchical.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list of Child objects. I would like to be able to
I have a parent page and child page, both aspx. All is working, but
I'd like to provide a button on my child page that would close the
I would like to use custom tag into my html page and use jquery
From the main page I would like to open a child window and from
I want to change master page some label value from child page.
I am using iframe to open new .aspx page from parent page. child page
I'd like to have a page that uses a child master page, fill in
in my application i am using master page and child pages. my requirement is
I would like access the IFrame element available in the main page from the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.