Breadcrumb trail
-
For those wishing to use a non-plugin based breadcrumb trail, simply insert the following code in functions:
function breadcrumb() { // Check if Permalinks are enabled $breadcrumb = array(); // Get current post $current = $post->ID; // Check if current post has ancestors if($GLOBALS['post']->ancestors) { $ancestors = $GLOBALS['post']->ancestors; // Step through ancestors array to build breadcrumb foreach($ancestors as $i => $text) { $breadcrumb[$i] = '<a href="' . get_page_link($text) . '" title="' . attribute_escape(apply_filters('the_title', $text->post_title)) . '">'.get_the_title($text).'</a>';} } // Insert a link to home array_unshift($breadcrumb, '<a href="' . get_option('home') . '" alt="Home" title="Home">Home</a>'); $breadcrumb[] .= '<a href="' . get_page_link($current->ID) . '" title="' . attribute_escape(apply_filters('the_title', $current->post_title)) . '">'.get_the_title($current).'</a>'; // Display breacrumb with demarcator echo implode(' > ', $breadcrumb); }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Breadcrumb trail’ is closed to new replies.