I want to display the title from a parent field within a single child post (these are custom posts created with wp-types).

At the moment, all I seem to get is the title of the current post, and not the parent.

Below is my markup.

<?php if (have_posts())  : while (have_posts()) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<div class="the-copy">
<?php the_content(); ?>
<div class="parent-title">
$parent_title = get_the_title($post->post_parent);
echo $parent_title;
<?php endwhile; ?>
<?php endif; ?>

Am I doing something wrong or have I missed something?

Thanks for you help, from what I can see this should be simple but it's just not working for me.


Managed to find the solution here

Essentially, as I was using the Types plugin standard parent / child wordpress code wouldn't work

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.