Get parent info within functions.php
-
I am trying to build a breadcrumb for my site that will include the parent to any given page. I have taken a php which when I put directly in my page.php works fine.
However I want my breadcrumb to part of my functions file as I will no doubt use it in future projects. However, the code below simply returns the current page info twice, and not the parent and then the page.
expected output = Parent Page >> Actual Page
actual output = Actual Page >> Actual PageI can’t see why this is not working as it seems a pretty simple code…
elseif (is_page()) {
$parent_title = get_the_title($post->post_parent);
echo ‘<a href=”‘;
echo get_permalink($post->post_parent);
echo ‘”>’;
echo $parent_title;
echo ‘ » ‘;
echo the_title();
}
- The topic ‘Get parent info within functions.php’ is closed to new replies.