Custom module - remove Genesis breadcrumbs

Hi, I’m making a custom module that will allow me to place the breadcrumbs in a different location than the default crumbs, and at the same time remove the default crumbs (using php, not css). So when the BB module is dragged onto the page, it will remove the default and relocate it where the BB module is located.

I’m using Genesis with Yoast SEO, so manually adding the crumbs to the frontend.php file using:


if (function_exists('yoast_breadcrumb' ) ) {
	yoast_breadcrumb('<div class="breadcrumb" itemprop="breadcrumb">','</div>');
}

I’m trying to remove the breadcrumbs using:


remove_action( 'genesis_after_header', 'genesis_do_breadcrumbs' );

The remove action is not working, but will work if I add it to my functions.php file. I’ve tried using after theme setup and a couple other hooks with no success.

Please help me figure out what I’m missing.

Thank you!

Hey Ray,

I believe the remove_action call isn’t working because that action has probably already fired by the time the module has rendered. Modules render in the content and the action is called genesis_after_header, so my guess is that action is called before any content is rendered. Your best bet is to include it in your functions.php file.

Justin

Hi Justin,

Thanks for your reply! I thought that might be the case.

Can you recommend a way to check if this specific module is active on a page, so I can add it to my functions.php and use a conditional for pages with this module loaded?

Thank you.

Hey Ray,

That’s possible, but would require some custom PHP to accomplish. You can start by pulling all of the builder data for the current post using…

if ( FLBuilderModel::is_builder_enabled() ) {
    global $post;
    $data = get_post_meta( $post->ID, '_fl_builder_data', true );
    // print_r( $data ); This will show you what's contained in the $data array. 
    // Loop through the data and look for your module.
}

From there you’ll need to loop through the data and check to see if your module is active.

Justin

Thank you. I output the array, but not sure what I’m looking for in there to check if the module is active on the page.

It looks like I will have to go with a more manual solution.

Hey Ray,

You’ll want to loop through the items and check for the type like this…

if ( $item->type == 'module' && $item->settings->type == 'your-module-slug' ) {
    // It's on the page.
}

Justin

Thanks Justin, that really helps! I’ll give this a shot and let you know how it works out. Really appreciate your help.

Maryam,

any news on your module?