Advertisement
mbis

Breadcrums NavXT

Feb 2nd, 2023 (edited)
666
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.75 KB | None | 0 0
  1. /**
  2.  * Change Breadcrumb NavXT trail to match Permalink Manager custom permalink structure.
  3.  *
  4.  * @param array $trail
  5.  *
  6.  * @return array
  7.  */
  8. function pm_breadcrumbs_navxt_trail( $trail ) {
  9.     if ( property_exists( $trail, 'breadcrumbs' ) ) {
  10.         $new_breadcrumbs = apply_filters( 'wpseo_breadcrumb_links', $trail->breadcrumbs );
  11.  
  12.         if ( count( $trail->breadcrumbs ) > 2 ) {
  13.             foreach ( $new_breadcrumbs as $i => &$breadcrumb ) {
  14.                 // Ignore first and last breadcrumb
  15.                 if ( ! is_array( $breadcrumb ) || empty( $breadcrumb['text'] ) ) {
  16.                     continue;
  17.                 }
  18.  
  19.                 $breadcrumb = new bcn_breadcrumb( $breadcrumb['text'], null, array( '' ), $breadcrumb['url'], null, true );
  20.             }
  21.         }
  22.     }
  23. }
  24. add_action( 'bcn_after_fill', 'pm_breadcrumbs_navxt_trail' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement