Home › Forums › General Issues › gettimg custom field values from parent and grandparent page? › Reply To: gettimg custom field values from parent and grandparent page?
this way i get the title of the parent page, maybe the code helps you:
<?php if(is_page()):
$toppage=array_reverse(get_post_ancestors($post->ID));
if($toppage[1]){
echo '<h1 class="site-title">'.get_the_title($toppage[1]).'</h1>';
}
endif;
?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.