When we change the language of the site while trying to add an event to our website, a 404 error message appears. However, this issue is now fixed with a simple code that needs to be pasted in the function.php. Now the error message does not appear while adding an event after changing the language. Or you can create a child theme and paste the code in the child theme’s function.php
Here is the code
add_action(
'init'
,
function
() {
if
(is_admin()) {
return
;
}
$current_locale
= get_locale();
$flushed_locale
= get_option(
'last_flushed_locale'
);
if
(
$current_locale
!==
$flushed_locale
) {
flush_rewrite_rules(false);
update_option(
'last_flushed_locale'
,
$current_locale
);
}
});