I'm running the following code:

 add_filter('locale', 'set_my_locale');
 function set_my_locale( $lang ) {
   $lang = "de";
   echo 'test';
   return $lang;

This is returning the correct 'de' language, but it is echoing out the 'test' 5 times.

Why is it echoing the 'test' 5 times?

The reason that I have the echo 'test'; in there is because I want to do some other checks in this function but it seems to run 5 times for some reason.

1 Answer 1


This is the expected behaviour. The locale filter is filtering the result of the get_locale() function. All this means is that get_locale() is being called at least 5 times.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.