Filter url and title

#807
  • Resolved Artem
    Rank Math free

    Hello
    I try write filter for include or exclude something from breadcrumbs. Here is my code for this

    add_filter( ‘rank_math/frontend/breadcrumb/items’, function( $crumbs, $class ) {
    if ( is_page(11)) {
    $breadcrumb[] = array(
    ‘url’ => ‘/myurl/’,
    ‘text’ => ‘My title’,
    );

    array_splice( $crumbs, 1, -5, $breadcrumb );
    }

    return $crumbs;
    }, 10, 2);

    But I have that Notices:

    Notice: Undefined offset: 1 in /mysite.com/wp-content/plugins/seo-by-rank-math/includes/modules/rich-snippet/snippets/class-breadcrumbs.php on line 52

    Notice: Undefined offset: 0 in /mysite.com/wp-content/plugins/seo-by-rank-math/includes/modules/rich-snippet/snippets/class-breadcrumbs.php on line 53

    Notice: Undefined offset: 0 in /mysite.com/wp-content/plugins/seo-by-rank-math/includes/frontend/class-breadcrumbs.php on line 119

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello,

    Thank you for contacting Rank Math today.

    Please use below filter code to change the Breadcrumbs data:

    
    add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
    	// if ( is_page(11)) {
    		$breadcrumb[] = array(
    			0 => 'My title',
    			1 => '/myurl/',
    		);
    		array_splice( $crumbs, 1, -5, $breadcrumb );
    	// }
      return $crumbs;
    }, 10, 2);
    

    Where 0 is the Breadcrumb text and 1 is the Breadcrumb link.

    Hope that helps. Thank you.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this ticket.