How to display breadcrumb on category?

If you’re dealing with the default “Category” taxonomy and the post post type, then you can get the post’s attached category terms with get_the_category(). $categories = has_category( $post ) ? get_the_category( $post ) : array(); The has_category() check is there just to fend off other post type posts. get_the_category() gives you an array of categories … Read more

How to add breadcrumbs to any WordPress theme

Try a breadcrumbs plugin. Breadcrumb NavXT is a popular option I believe. An alternative solution of is just printing the name of the current page. Here’s what such a function might look like in its most basic form: function wpse_87332_nav_identifier() { $page_name = get_the_title(); echo “You are here: ” . $page_name; } Note that this … Read more

custom post type breadcrumb error when has_archive = false

Just grabbed a snippet from the get_cpt_crumb() function in the genesis breadcrumbs class file (/lib/classes/breadcrumb.php) protected function get_cpt_crumb() { $post_type = get_query_var( ‘post_type’ ); $post_type_object = get_post_type_object( $post_type ); if ( $cpt_archive_link = get_post_type_archive_link( $post_type ) ) $crumb = $this->get_breadcrumb_link( $cpt_archive_link, sprintf( __( ‘View all %s’, ‘genesis’ ), $post_type_object->labels->name ), $post_type_object->labels->name ); else $crumb = … Read more

Back button to previous page and breadcrumbs

For the button behavior, If it’s a one-off use case, you could add custom php conditional to check the referring url $_SERVER[‘HTTP_REFERER’] and current page/post ID or url. Then, either add a class to the button’s containing div wrapper in the template for hiding via css or directly output/include the button html in the template … Read more

Only show sub-category

You can make use of the get_the_categories filter to remove the parent categories from the list. the_category() uses get_the_category_list() which in turn uses get_the_category() The idea is to check the categories returned against an array of parent ids and then removing those categories from the list. You can try the following (Requires PHP 5.3+) add_filter( … Read more