BuddyBoss 404 Errors

Some BuddyBoss users report spontaneous 404 errors across multiple, or all, pages and posts that is resolved by re-saving permalinks in WP admin. If these 404 errors occur on your website, debugging can be challenging, and for many of us, the exact cause has yet to be determined.

A solution that has been offered by the community is to flush the permalinks when a 404 error is received. That way, if the 404 is a mistake that can be resolved by flushing the permalinks, the visitor will be directed to the expected page. The code below can be added to your child theme’s functions.php to achieve this.

function flush_perma_on_404(){
//flush permalinks if user gets 404
if( is_404() ){
global $wp;
$check = get_transient( 'permalinks_flushed_recently' );
if ( $check === false ) {
flush_rewrite_rules();
set_transient( 'permalinks_flushed_recently', 'yes', 50 * MINUTE_IN_SECONDS );
wp_redirect(home_url( $wp->request ));
exit;
}
}
}
add_action( 'template_redirect', 'flush_perma_on_404' );

Eric Lane is the lead customer success agent at Foxlypress, where he combines his passion for technology with his dedication to helping clients achieve their online goals.

A long-time resident of San Diego County, Eric's love for the outdoors is matched only by his enthusiasm for web development and customer service. When he's not assisting clients with their BuddyBoss and WordPress needs, you can find Eric exploring the diverse landscapes of Southern California.

His unique blend of technical expertise and approachable demeanor makes Eric an valued asset to the Foxlypress team and a trusted advisor to clients navigating the world of online community building.

One comment

  1. One of the challenges we’re experiencing with this code snippet is that opcache may have to be manually flushed depending on your hosting provider.

Leave a Reply

Your email address will not be published. Required fields are marked *