Skip to main content

Posts

Showing posts from July 18, 2014

Custom breadcrumb list in wordpress

While developing a custom plugin for a website I needed to post a custom breadcrumb trail. Articles on this website are based on a custom post type and some of them were very deep in hierarchical order.  (Example : Knowledgebase > Indian Mining Regulations > DGMS > Mining Legislation > Safety Conferences on Safety in Mines > X - Safety Conference) I wanted to put a series of links for visitor to follow the progression of contents. So, I thought about giving them breadcrumb trails to follow it back to wherever they want to go in the series. After some google search and some modifications: here is what I created. Hope, it may help you. This is for a custom post type of hierarchical in nature, but it can also be used for pages or other post types having hierarchies. function fn_nova_breadcrumb_trail($post) { $separator = '  > '; $trail_posts = array($post); $parent = $post; $current_post_id=$post->ID; while($parent->post_parent) {