Created
June 5, 2012 18:15
-
-
Save hsquareweb/2876656 to your computer and use it in GitHub Desktop.
WP: Dynamic Breadcrumbs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div id="breadcrumbs"> | |
| <a href="<?php echo get_bloginfo('url'); ?>" title="">Home</a> | |
| <?php | |
| $parent_id = $post->post_parent; | |
| $breadcrumbs = array(); | |
| while ($parent_id) { | |
| $page = get_page($parent_id); | |
| $breadcrumbs[] = '<a href="'.get_permalink($page->ID).'" title="'.get_the_title($page->ID).'">'.get_the_title($page->ID).'</a>'; | |
| $parent_id = $page->post_parent; | |
| } | |
| $breadcrumbs = array_reverse($breadcrumbs); | |
| foreach ($breadcrumbs as $crumb) echo ' / '.$crumb; | |
| ?> | |
| </div> | |
| <h1><?php the_title(); ?></h1> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment