breadcrumbs no entry type
-
Hello, I created my own post type and taxonomy for it.
When I log in, I still get breadcrumbs.
Головна » На сторінках преси » 2022 » Випуск 17
but when I go to the taxonomy, I get these breadcrumbs
Головна » 2022
no On pages press (post type) how can this be fixed
Tell me how to solve this problem
-
Hello @madcrach,
Thank you for contacting Rank Math support.
Please share the URLs of a post & taxonomy from your custom post type so we can check and assist you further.
Looking forward to helping you.
This is how I register my taxonomy and my data type
add_action('init','poster'); function poster() { register_post_type('poster',array( 'public'=>true, 'supports' => array('title', 'editor'), 'menu_position' => 11, 'menu_icon' => 'dashicons-calendar-alt', 'taxonomies' => ['poster_year'], 'has_archive' => true, 'show_in_rest' => true, 'labels' => array( 'name' => 'Анонс заходів', 'all_items' => 'Усі заходів', 'add_new' => 'Додати захід', 'add_new_item' => 'Анонс заходів' ) )); } // хук для регистрации add_action( 'init', 'create_taxonomy_poster_year' ); function create_taxonomy_poster_year(){ // список параметров: wp-kama.ru/function/get_taxonomy_labels register_taxonomy( 'poster_year', [ 'poster' ], [ 'label' => '', // определяется параметром $labels->name 'labels' => [ 'name' => 'Рік', 'singular_name' => 'Рік', 'search_items' => 'Пошук', 'all_items' => 'Усі ', 'view_item ' => 'Переглянути', 'parent_item' => 'Батько', 'parent_item_colon' => 'Батько:', 'edit_item' => 'Редагувати', 'update_item' => 'Оновити', 'add_new_item' => 'Додати рік', 'new_item_name' => 'Новий рік', 'menu_name' => 'Рік', 'back_to_items' => '← Назад', ], 'description' => '', // описание таксономии 'public' => true, // 'publicly_queryable' => null, // равен аргументу public // 'show_in_nav_menus' => true, // равен аргументу public // 'show_ui' => true, // равен аргументу public 'show_in_menu' => true, // равен аргументу show_ui // 'show_tagcloud' => true, // равен аргументу show_ui // 'show_in_quick_edit' => null, // равен аргументу show_ui 'hierarchical' => true, 'rewrite' => true, //'query_var' => $taxonomy, // название параметра запроса 'capabilities' => array(), 'meta_box_cb' => null, // html метабокса. callback:post_categories_meta_boxилиpost_tags_meta_box. false — метабокс отключен. 'show_admin_column' => false, // авто-создание колонки таксы в таблице ассоциированного типа записи. (с версии 3.5) 'show_in_rest' => true, // добавить в REST API 'rest_base' => null, // $taxonomy // '_builtin' => false, //'update_count_callback' => '_update_post_term_count', ] ); }here is a link to my post type,
Here’s the taxonomy, there are no post type breadcrumbs here
Here is the full record, here it is normal to display bread crumbs
That is, the problem is that the taxonomy does not display the type of posts
Hello @madcrach,
At the moment, our plugin doesn’t fully support custom taxonomy when generating the breadcrumbs on taxonomy pages.
However, please head over to your WordPress Dashboard > Rank Math > General Settings > Breadcrumbs and ensure that the option “Hide Taxonomy Name” is disabled.
If that doesn’t help, we have provided a filter code to customize the breadcrumbs for this type of page further. You may refer to this filter code: https://rankmath.com/kb/filters-hooks-api-developer/#change-remove-breadcrumb-items
Let us know how that goes. Looking forward to helping you.
I solved the problem like this
add_filter('rank_math/frontend/breadcrumb/items', function ($crumbs, $class) { $queried_object = get_queried_object(); if (is_tax() && is_object($queried_object)) { $term = $queried_object; $taxonomy = $term->taxonomy; $post_type = get_taxonomy($taxonomy)->object_type[0]; $post_type_object = get_post_type_object($post_type); if ($post_type_object) { $post_type_name = $post_type_object->labels->name; $post_type_crumb = array( $post_type_name, get_post_type_archive_link($post_type), ); array_splice($crumbs, 1, 0, array($post_type_crumb)); } } return $crumbs; }, 10, 2);-
This reply was modified 2 years, 6 months ago by
madcrach.
Hello @madcrach,
We are glad that you were able to modify the filter to resolve the issue. Thank you so much for sharing the solution here, as it will be helpful for other users who want to do the same.
Please do not hesitate to let us know if you need our assistance with anything else.
-
This reply was modified 2 years, 6 months ago by
The topic ‘breadcrumbs no entry type’ is closed to new replies.