-
Hello,
I hardly know programming. I’m trying to get the code to get the following:
– Inject some personalized breadcrumbs for posts stored in a specific category.
– The structure of the crumbs would be: Custom element 1> Custom element 2> Post titleadd_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) { if(is_category('ID-Cat')){ $value1[] = array( 'Custom Page1', 'http://localhost/cutompage1', 'hide_in_schema' => false ); $value2[] = array( 'Custom Page2', 'http://localhost/cutompage2', 'hide_in_schema' => false ); array_splice( $crumbs, 1, 0, $value ); return $crumbs; } return $crumbs; }, 10, 2);
I have tried with this, but nothing, not even the custom crumbs are printed in the posts of the indicated category.
A help please!
PS: I don’t even know who to ask
PS 2: I am already using these two filters on the site:add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) { $breadcrumb[] = array( 0 => 'Turismo León Provincia', 1 => '/leon-provincia/', ); array_splice( $crumbs, 1, -5, $breadcrumb ); if(is_singular('post')){ unset($crumbs[0]); $crumbs = array_values($crumbs); return $crumbs; } return $crumbs; }, 10, 2);
add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) { if (is_page( '' )){ $value[] = array( 'Taberna Gaia', '/', 'hide_in_schema' => false ); unset($crumbs[1]); array_splice( $crumbs, 0, -2, $value ); return $crumbs; } return $crumbs; }, 10, 2);
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
The ticket ‘Help with code for custom breadcrumbs’ is closed to new replies.