fauzanjeg

Custom Breadcrumb for Category and Tag

Mar 16th, 2021 (edited)
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.79 KB | None | 0 0
  1. /* Custom Breadcrumb for Category and Tag */
  2. function jnews_breadcrumb_call_custom( $data ) {
  3.     if ( is_category() || is_tag() ) {
  4.         remove_filter( 'jnews_breadcrumb', 'jnews_breadcrumb_call' );
  5.         $id = get_queried_object()->term_id;
  6.         $parent = JNews_Breadcrumb::getInstance();
  7.         $breadcrumb = array();
  8.         $breadcrumb[] = $parent->breadcrumb_text( home_url(), jnews_return_translation( 'Home','jnews-breadcrumb', 'home' ) );
  9.    
  10.         $parent->recursive_category( $id, $breadcrumb, true );
  11.    
  12.         $breadcrumb = implode( "<i class=\"fa fa-angle-right\"></i>", $breadcrumb );
  13.         $breadcrumb = "<div id=\"breadcrumbs\">$breadcrumb</div>";
  14.    
  15.         return apply_filters( 'jnews_native_breadcrumb_category', $breadcrumb, $id );
  16.     }
  17.     return $data;
  18. }
  19.  
  20. add_filter( 'jnews_breadcrumb', 'jnews_breadcrumb_call_custom' );
Add Comment
Please, Sign In to add comment