admin管理员组文章数量:1125387
I’d like to get the breadcrumbs to show the category path on single posts. On the subcategory pages, I’ve got Blog>Category>Subcategory which is perfect. Example here:
However I’m unable to achieve this on single posts, where it just shows Blog>Post title. Example here:
Can you help, please?
Many thanks, Micheal Kean
I’d like to get the breadcrumbs to show the category path on single posts. On the subcategory pages, I’ve got Blog>Category>Subcategory which is perfect. Example here: https://mechanicalmentor.com/engineering/industrial-robotics
However I’m unable to achieve this on single posts, where it just shows Blog>Post title. Example here: https://mechanicalmentor.com/robot-programming-languages
Can you help, please?
Many thanks, Micheal Kean
Share Improve this question edited Dec 29, 2023 at 16:42 fuxia♦ 107k38 gold badges255 silver badges459 bronze badges asked Dec 29, 2023 at 12:51 Micheal KeanMicheal Kean 1 1- Breadcrumbs aren't part of WordPress core, so this is a question for the support team theme or plugin you're using to provide them. – Pat J Commented Dec 29, 2023 at 15:09
2 Answers
Reset to default 1Default Wordpress doesn't have any breadcrumbs.
My guess is that your breadcrumbs are added by the plugin Rank Math (which seems to be installed on your site). So just go to the settings for your plugin and add categories to the breadcrumbs.
really it depends on the theme you are using. Please backup your site before trying any of these changes. You can possibly add them like this:
- Open your theme functions.php file
- Add this code
function wpb_custom_breadcrumbs() {
// Breadcrumbs for single post
if (is_single()) {
global $post;
$categories = get_the_category($post->ID);
if ($categories) {
$output = '<a href="' . get_permalink(get_option('page_for_posts')) . '">Blog</a> » ';
foreach ($categories as $category) {
$output .= '<a href="' . get_category_link($category->term_id) . '">' . $category->name . '</a> » ';
}
$output .= get_the_title();
return $output;
}
}
// Your existing breadcrumb code here for other page types...
}
Then find and edit your single.php file and add this code where the breadcrumb displays:
<?php echo wpb_custom_breadcrumbs(); ?>
Or
echo wpb_custom_breadcrumbs();
本文标签: Categories Not Showing in breadcrumbs in posts
版权声明:本文标题:Categories Not Showing in breadcrumbs in posts 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736651162a1946142.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论