After hours of googling “Enfold breadcrumbs remove blog page” and dozens of other similar searches, I finally figured out how to remove the Blog page from your Enfold breadcrumbs.
The fix for this is almost identical to the dozens of Kriesi/Enfold forum threads explaining how to remove the category slug. The only difference is which lines of code need to be changed.
In order to implement this fix, I strongly recommend you use a Child Theme.
The Kriesi.at folks seem to be ok with editing the Enfold theme files. I don’t recommend that. Child Themes are much safer.
[blog_stripe]1. Find class-breadcrumb.php file
As noted above, you pretty much have to use a Child Theme of Enfold, otherwise this change is all for naught. But even though you’re using a Child Theme, you have to start in the Enfold core files.
Open up the file /wp-content/themes/enfold/framework/php/class-breadcrumb.php.
You’ll need to copy a few hundred lines of that file and paste them into your Child Theme’s functions.php file.
[/blog_stripe]2. Copypasta the avia_breadrumbs() function
Copy from line 149-150:
/*-----------------------------------------------------------------------------------*/ /* avia_breadcrumbs() - Custom breadcrumb generator function */
…to line 520:
} // End avia_breadcrumbs()
Paste those 371 lines into your functions.php file.
Important: if you’re not using a Child Theme, pasting these lines into the Enfold functions.php file could break your site.
Be careful. And use a damn Child Theme, damn it.
[blog_stripe]3. Find functions-enfold.php file
Just like step 1 above, you’ll need to open up a core Enfold file to grab a function.
Open /wp-content/themes/enfold/functions-enfold.php. And again you’ll copy some code and paste it into your Child Theme’s functions.php file.
[/blog_stripe]4. Copypasta the avia_title() function
Copy from line 295-296:
//advanced title + breadcrumb function if(!function_exists('avia_title'))
…to line 364-367:
return $html; } } }
Paste those 72 lines into your functions.php file.
Still important: if you’re not using a Child Theme, pasting these lines into the Enfold functions.php file could break your site. Be careful.
And use a damn Child Theme, damn it!
[blog_stripe]5. Rename avia_breadcrumbs() function or get a fatal PHP error
So far, all we’ve done is duplicate code without changing any functionality. And if you stop here, you’ll get a fatal PHP error since we’re trying to declare the avia_breadcrumbs() function twice.
The next step is to rename avia_breadcrumbs() to something similar.
I named mine tjk_breadcrumbs(), but your mileage may vary.
Maybe childtheme_breadcrumbs(), or custom_breadcrumbs() or something similar. Whatever you’re into.
Keep track of your new function’s name. We’ll need it in the next step.
We don’t have to rename the avia_title() function because it’s wrapped in an if(!function_exists(‘avia_title’)) conditional.
Ours will be rendered first because it’s in a Child Theme, which means that the Enfold version of this function fails the if !function_exists condition and is never redeclared.
Thus no fatal error. Thanks, Kriesi!
[/blog_stripe]6. Change call to avia_breadcrumbs()
Toward the bottom of the avia_title() function, you’ll see this line:
if($breadcrumb) $additions .= avia_breadcrumbs(array('separator' => '/', 'richsnippet' => true));
Duplicate that line and comment out the top one. Now your code should look like this:
//if($breadcrumb) $additions .= avia_breadcrumbs(array('separator' => '/', 'richsnippet' => true)); if($breadcrumb) $additions .= avia_breadcrumbs(array('separator' => '/', 'richsnippet' => true));
Change the avia_breadcrumbs bit to match whatever you changed your function name to in step 5.
In my case, it says tjk_breadcrumbs(array(‘separator’. Now your code should look like this:
//if($breadcrumb) $additions .= avia_breadcrumbs(array('separator' => '/', 'richsnippet' => true)); if($breadcrumb) $additions .= custom_breadcrumbs(array('separator' => '/', 'richsnippet' => true));
If you forget this step, none of the changes you make in the next steps will show up and you’ll think I wrote a bad tutorial.
I didn’t.
So please get his one right.
[blog_stripe]7. Modify custom_breadcrumbs() function
In your custom-named breadcrumbs function, look for these lines about one third of the way down (line 100 out of 350 if your function starts on line 1):
/* Toggle the display of the posts page on single blog posts. */ if ( 'post' == $post_type && $show_posts_page == true && 'page' == get_option( 'show_on_front' ) ) { $posts_page = get_option( 'page_for_posts' ); if ( $posts_page != '' && is_numeric( $posts_page ) ) { $trail = array_merge( $trail, avia_breadcrumbs_get_parents( $posts_page, '' ) ); } }
Comment out that entire block. You could probably delete it too, but commenting-out is safer in case you ever want it back.
/* Toggle the display of the posts page on single blog posts. */ /* if ( 'post' == $post_type && $show_posts_page == true && 'page' == get_option( 'show_on_front' ) ) { $posts_page = get_option( 'page_for_posts' ); if ( $posts_page != '' && is_numeric( $posts_page ) ) { $trail = array_merge( $trail, avia_breadcrumbs_get_parents( $posts_page, '' ) ); } } */
Save the functions file and refresh your active-Enfold Child Theme site.
You should see your breadcrumbs looking something like Home > Category > Post Name.
[/blog_stripe]Ok, but why? What’s the use case?
In my case, it’s for UI cleanliness reasons. A perfect storm of unrelated factors add up to needing to remove the Blog index from the breadcrumbs.
- Enfold has its Portfolio custom post type with permastruct “front” slugs enabled.
- My posts have sub-categories: category Books might have sub-categories of Hardcover and Paperback, eg.
- I want /blog/ in the post and archive permalinks: domain.com/blog/[stuff here]
- I also want the category slug in the single post permalinks: /%category%/%postname%/
If I add /blog/ to the permalink structure (domain.com/blog/%category%/%postname%/), here’s what happens:
I’ll end up with /blog/ in the Enfold Portfolio slugs: domain.com/blog/portfolio/item-slug/. I definitely don’t want that, since these things are not blog content.
My solution is to remove /blog/ from the permalink structure and create a category called Blog.
Then every blog post uses categories which are technically sub-categories of Blog:
It’s a hacky solution, but achieves my outcome so I’m happy with it. It leaves me with URLs like domain.com/blog/estate-planning/start-a-trust-fund/.
Great for UX and SEO alike.
[blog_stripe]Full circle.
This leads me back to breadcrumbs. Because Blog is technically a category, Enfold throws it into the breadcrumbs by default.
I ended with this…
Home > Blog > Blog > Estate Planning > Start a Trust Fund
…which amounted to this…
Home > Blog Index Page > Blog Hacky Category > Desired Sub-Category > Post Name
Obviously the duplicate “Blog >” was stuff was problematic.
I considered hiding one of the Blog > crumbs with CSS, but I didn’t like the idea of Google indexing the pages with bad breadcrumbs.
Maybe I made a mountain out of a molehill, but I did it anyway.
So after some digging and reading Kriesi’s forums, I finally figured out how to remove the Blog index page.
There you have it.
Blog index page is removed from Enfold’s breadcrumbs and my client’s site has clean URLs and breadcrumbs.
I’ll keep using the hack method until WordPress releases a better way to deal with permastruct/front values in posts vs. custom post types.
I know there’s a way to remove the “use front” setting in the CPT, but since it’s bundled with Enfold, I decided not to mess with it.
This method works for me. I hope it helps someone else out there too.
[/blog_stripe]
Here’s my solution:
1. Remove the /blog permalink category base via WordPress settings.
2. Add to .htaccess file (to avoid the duplicate pages being indexed):
Redirect 301 /category/blog /blog
3. Use the following CSS to prevent the second “Blog” breadcrumb and separator from showing:
.breadcrumb-trail > span:nth-child(6),
.breadcrumb-trail > span:nth-child(7) {
display: none !important;
}
(CSS may need to be adjusted depending on how your breadcrumbs and site are structured)
Does this achieve the same outcome?
Hi there, thanks for your comment.
Yes, that achieves the same outcome but I wanted a PHP-based solution, rather than just hiding with CSS.
Most users wouldn’t know the difference between my solution and yours, so I’d consider that a win. Thanks for sharing!