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 7664415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:17:57+00:00 2026-05-31T14:17:57+00:00

I created a hierarchical custom post type called films. It is hierarchical so it

  • 0

I created a hierarchical custom post type called “films.” It is hierarchical so it can have children elements.

I am using a conditional statement in my single-films.php to show different content for the parent page from the children pages like so:

<?php while(have_posts()) : the_post(); ?>

<?php if( $post->post_parent != 0 ) {
    echo "Child Page";
} else {
    echo "Film Page";
} ?>
<?php endwhile; ?>

In the condition that the page is a child, I want to use the values entered on the parents page, not the child page. Because the loop has already been created, I need to figure out a way to pull content from the parent page JUST on the children pages. I need it to pull any content I wish (custom field, title, featured image, etc) from it’s parent. Any idea how I can modify this loop to pull content from it’s parent?

  • 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-05-31T14:17:58+00:00Added an answer on May 31, 2026 at 2:17 pm

    WordPress has a nice get_post function, you can use it like this to get the parent’s title for example:

    <?php 
    
    if ($post->post_parent != 0) {
      $parent = get_post($post->post_parent); 
      echo $parent->post_title;
    } ?>
    

    You can access any custom field by its key/name and the parent’s post id:

    <?php
    
    $image = wp_get_attachment_image_src(get_post_meta($post->post_parent, 'custom-field-key', true));
    echo '<img src="' . $image[0] . '" />';
    ?>
    

    This works for sure with the Advanced Custom Fields Plugin for WordPress.

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

Sidebar

Related Questions

I have created a custom post type of 'portfolio' and page with a template
I'm using a custom taxonomy and a custom post type: <?php function my_custom_taxonomies() {
I have a similar problem with this ( https://wordpress.stackexchange.com/questions/9593/custom-post-type-archive-with-pagination ) and can't really figure
I have a custom post type of Products in my WordPress project. The CPT
I created a few mediawiki custom tags, using the guide found here http://www.mediawiki.org/wiki/Manual:Tag_extensions I
For those Telerik gurus out there, I have a Hierarchical DataGrid that is created
I'm adding my hierarchical data to a Menu-Control using the HierarchicalDataTemplate. <HierarchicalDataTemplate DataType={x:Type local:MyType}
I am considering using django-cms to implement the following scenario: Admins can create hierarchical
I'm using Custom Post Template which I linked to Magic Fields to create custom
I set up a custom content type called photo which is working fine. Now

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.