Flush urls

/**
* Final Redirect Fix for Alternatives Migration
* Ensures all redirects work correctly
* Run once then deactivate
*/

add_action(‘init’, function() {
if (get_transient(‘zeevou_final_redirects_done’)) {
return;
}

// Flush permalinks to activate any API-created redirects
flush_rewrite_rules(true);

set_transient(‘zeevou_final_redirects_done’, true, HOUR_IN_SECONDS);
}, 999);

// Add template redirects as backup if API redirects don’t work
add_action(‘template_redirect’, function() {
$request_uri = $_SERVER[‘REQUEST_URI’];

// Redirect old blog posts to new alternatives
$redirects = [
‘/blog/liverez-alternatives/’ => ‘/alternatives/liverez/’,
‘/blog/liverez-alternatives’ => ‘/alternatives/liverez/’,
‘/blog/transform-your-str-business-with-streamline-alternatives/’ => ‘/alternatives/streamline/’,
‘/blog/transform-your-str-business-with-streamline-alternatives’ => ‘/alternatives/streamline/’,
‘/alternatives/liverez-3/’ => ‘/alternatives/liverez/’,
‘/alternatives/liverez-3’ => ‘/alternatives/liverez/’,
‘/alternatives/liverez-2/’ => ‘/alternatives/liverez/’,
‘/alternatives/liverez-2’ => ‘/alternatives/liverez/’,
];

foreach ($redirects as $from => $to) {
if (rtrim($request_uri, ‘/’) === rtrim($from, ‘/’)) {
wp_redirect(home_url($to), 301);
exit;
}
}
}, 1);

// Show confirmation notice
add_action(‘admin_notices’, function() {
if (!get_transient(‘zeevou_final_redirects_done’)) {
return;
}

echo ‘

‘;
echo ‘

✅ Migration Complete!

‘;
echo ‘

Live URLs:

‘;
echo ‘

‘;
echo ‘

Redirects (test these):

‘;
echo ‘

‘;
echo ‘

You can deactivate this snippet after verifying redirects work.

‘;
echo ‘

‘;
});

Scroll to Top
Solution lamp for mobile header

Custom Solutions with Zeevou

Discover tailored solutions perfectly suited to your role, business size, and specific use cases.