0

can't seem to get this but how can i load info in a child's page from its parent?

ie, i'm looking at an attachment and i can get the parents ID easy enough but not sure how to get the parents title, excerpt etc.

// attachment content above here then want to get and show some parents' content

echo $parent = get_post_field('post_parent', $id);

echo the_title(); // this still shows the childs title...

any help appreciated! Dan

1

You can try get_post($post->post_parent) or get_page($post->post_parent) so if you do:

$parent = get_post($post->post_parent);

You can get the title like this:

$parent->post_title;

And anything you want, you can var_dump($parent) to see all the post info you can use.

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.