I like working with parent- und childpages, since it holds a better overview in your backend, aswell pushes SEO, by defining dependencies between your pages.
Many WordPress Themes are using Breadcrumbs as a kind of Navigation and overview for the page visitor. These Breadcrumbs rarely link to parent pages, so I found a way to make a Breadcrumb appear like this:
I edited the file theme/includes/breadcrumbs.php of my ElegantTheme Foxy – I don’t know whether this will work with other themes as good as with ET Themes.
HowTo:
Locate the line looking familar to this:
1 |
<a class="breadcrumbs_home" href="<?php echo esc_url( home_url() ); ?>">< ?php esc_html_e('Home','Foxy') ?></a> <span class="raquo">»</span> |
This adds the Home-link aswell as a little arrow between the different links in our Breadcrumb (.raquo).
After this line the ET Breadcrumb should look like this: Home >
Now we want to add the parent page link. BUT… of course we want to link it only then, when there is one 😉
1 |
< ?php if($post->post_parent) { |
If there is one – let’s detect it’s name and permalink:
1 2 |
$parent_link = get_permalink($post->post_parent); $parent_title = get_the_title($post->post_parent);?> |
Next just add a link to the Breadrcrumb and finally also the next arrow (the one between parent- and childpage):
1 2 3 |
<a id="bread_parent_link" href="<?php echo $parent_link; ?>">< ?php echo $parent_title; ?></a> <span class="raquo">»</span> < ?php } ?> |
That’s it! Now we made our ElegantThemes Breadcrumbs showing Parent Pages!
Leave your comment if you need any further help 😉