Can anyone help me to hide breadcrumbs from certain page ID's?
I'm using the Breadcrumb NavXT plugin. I've only found out how to hide it from the home page.
I'm using this code in my header.php
:
if ( ! is_front_page() ) {
bcn_display();
}
Suppose you have set up an array of page IDs where you don't want the breadcrumbs to be displayed.
$ids = array( 4, 8, 15, 16, 23, 42 );
Now you just have to check if the currently displayed page (or post) has one of these IDs, and if not, display the breadcrumbs.
if ( ! in_array( get_the_ID(), $ids ) ) {
bcn_display();
}
// EDIT
And if you want to exclude pages only—no other (custom) posts—you could speed up the check a bit.
if (
! is_page()
|| ! in_array( get_the_ID(), $ids )
) {
bcn_display();
}
// EDIT (as per your comment)
To exclude the front page as well as specific pages, try this:
$ids = array( 4, 8, 15, 16, 23, 42 );
// Automagically add the ID of your front page
$ids[ ] = (int) get_option( 'page_on_front' );
if (
! is_page()
|| ! in_array( get_the_ID(), $ids )
) {
bcn_display();
}
is_front_page
, or get the front page ID (see my answer).