13
Jan
2012
Wordpress is one best open source application by which a well formed website can be made by beginner or an expert web designer. It is free and easy to use. From my personal experience I like its breadcrumb feature especially “Taxonomy” which gives a professional web design looks to my website. So I would like to share code for Custom Taxonomy Breadcrumbs with you.
Copy below code to your functions.php file:
Note: "$" is used for variable declaration
"echo()" is used to display content
"foreach" construct provides a simple way to iterate over arrays and it works only on arrays and objects.
Paste below code wherever you want to display taxonomy.
Source: free-php.net
Copy below code to your functions.php file:
Note: "$" is used for variable declaration
"echo()" is used to display content
"foreach" construct provides a simple way to iterate over arrays and it works only on arrays and objects.
| <?php function postTypeCrumbs($postType, $postTax) { $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); $taxonomy = get_taxonomy($term->taxonomy); $parents = get_ancestors( $term->term_id, $postTax ); $parents = array_reverse($parents); $archive_link = get_post_type_archive_link( $postType ); echo '<ul class="ax_crumbs">'; if ($taxonomy) { echo '<li><a href="' . $archive_link . '" title="' . $taxonomy->labels->name . '">' . $taxonomy->labels->name . '</a> » </li>'; } foreach ( $parents as $parent ) { $p = get_term( $parent, $postTax ); echo '<li><a href="' . get_term_link($p->slug, $postTax) . '" title="' . $p->name . '">' . $p->name . '</a> <span>»</span> </li>'; } if ($term) { echo '<li>' . $term->name . '</li>'; } echo '</ul>'; } ?> |
Paste below code wherever you want to display taxonomy.
| <?php postTypeCrumbs('post type', 'taxonomy name'); ?> |
Source: free-php.net

(0)
Comments
There isn't any comment in this page yet!Do you want to be the first commenter?