I'm looking for a button solution for breadcrumb.
I have a breadcrumb on the page that is under the header.
I would like to be able to turn it off / on on a given page / post.
I don't want to use an extra plugin.
Page settings = show or hide breadcrumb. I saw this option somewhere but I can't find the code.
Regards and thanks for help.
My Answer:
You can achieve this by adding a simple conditional statement in your theme's template files. Here's how you can do it:
1. Open your theme's header.php file and locate the code that displays the breadcrumb. It might look something like this:
php
2. Wrap this code in a conditional statement that checks if the breadcrumb should be displayed based on the page settings. For example, if you have a custom field named "hide_breadcrumb" that you can set to true or false on each page, you can modify the code like this:
php
$hide_breadcrumb = get_post_meta(get_the_ID(), 'hide_breadcrumb', true);
if (!$hide_breadcrumb && function_exists('bcn_display')) :
?>
3. Now, on the pages where you want to hide the breadcrumb, simply add a custom field named "hide_breadcrumb" with the value set to true.
That's it! The breadcrumb will now only be displayed on pages where the "hide_breadcrumb" custom field is not set to true.
Rate this post
4 of 5 based on 8449 votesComments