Site logo

Archived topic

breadcrumbs by yoast > how to exclude particular pages?

16 replies · Started by Christian on July 28, 2017

Viewing posts 1–15 of 17

Dear Support Team,

I am using Yoast breadcrumb functionality with GP 1.3.48.
I want to exclude the breadcrumbs from showing up on first level pages like the "home" or "start" pages.
I tried several solutions from this forum but without luck and would be very happy if you could help me with the code.
I use the following code in the hook premium plugin in "inside content container"
------------------------------------
<div style="font-size:12pt;

<?php
if ( function_exists('yoast_breadcrumb') ) {
yoast_breadcrumb('
<p id="breadcrumbs">','</p>
');
}
?>

------------------------------------

Thank you for your support, Best, Chris

Hi there,

What do you mean by start pages? We'd need to be more specific.

Maybe you only want them on single posts?

Hi Tom,
thank you for your reply.

My "first level navigation" looks like:

Start Main1 Main2 Main3 Main4 Each "Main" might have sublevels like:
sub1 subA
sub2 subB
sub3 subC

I only want to see the breadcrumbs on the sub-levels and not on the main level.

It is not around only seeing them on single posts - but on single pages (which might be the same in terms of code??)

If you need to look at the particular website: https://zenhub.org

Hopefully I was able to clarify more, thank you for your help and consideration, Best, Chris

Try this:

<?php if ( function_exists( 'yoast_breadcrumb' ) && is_singular() ) {
    yoast_breadcrumb( '<p id="breadcrumbs">','</p>' );
} ?>

HI Tom,

I would like to achieve this as well. Show breadcrumb only on second and third level pages and not first level. If I use the code you provided, it shows the breadcrumbs everywhere and stop the scrolling function.

Website: http://www.espressotranslations.com

Best,
Dan

What do you mean by first level? The code above will only display them on single pages.

If you want the breadcrumbs inside your sticky header, you'll want to include the code inside of your closing custom-fixed-header </div> element.

Hi Tom,

What I want to achieve is to exclude breadcrumbs when you are on the primary navigations pages. I want them to be displayed only when you are on subpages (pages inside the drop down menu under the arrows)

Thanks
Dan

I don't think there's a conditional that can do that.

You would have to manually enter the page IDs you want to include it one:

if ( is_page( array( 10, 12, 18, 20 ) ) ) {
    // Breadcrumb code in here
}

10, 12, 18 and 20 being the page IDs

Ok thanks. Where do I have to add this code?

Also, do I have to delete some code that I already have?

This is what I have now:

<?php if ( ! is_front_page() ) : ?>
<?php if ( function_exists('yoast_breadcrumb') ) { ?>

<?php yoast_breadcrumb('<p id="breadcrumbs">','</p>'); ?>

<?php } ?>
<?php endif; ?>

This is the code I added but it seems still to show on all pages:

if ( is_page( array( 637 ) ) ) {
<?php if ( ! is_front_page() ) : ?>
<?php if ( function_exists('yoast_breadcrumb') ) { ?>

<?php yoast_breadcrumb('<p id="breadcrumbs">','</p>'); ?>

<?php } ?>
<?php endif; ?>
}

This would be your code:

<?php if ( function_exists('yoast_breadcrumb') && ! is_front_page() && is_page( array( 637 ) ) ) : ?>
    <?php yoast_breadcrumb( '<p id=”breadcrumbs”>','</p>' ); ?>
<?php endif; ?>

Thanks a lot Tom! :)

You're welcome :)

Hi!

I have set up breadcrumbs with the Yoast plugin. Then I used GP Hooks and the following code for displaying breadcrumbs everywhere except on the homepage, and it works fine:

<?php if ( ! is_front_page() ) : ?>
<?php
if ( function_exists('yoast_breadcrumb') ) {
yoast_breadcrumb('
<p id="breadcrumbs">','</p>
');
}
?>
<?php endif; ?>

But I have created a new landing page, and I want to exclude breadcrumbs also on such page.

How should I modify the above-mentioned code for displaying breadcrumbs on the whole site EXCEPT on the homepage and the landing page?

(The id of the landing page is 8191, and the site I'm working on is rusketa.com)

I love GeneratePress, many thanks for your work and assistance! :-)

This archived topic is closed to new replies.