You’re right, it also works when I remove the filter inside the function right before the return statement. Not sure, maybe I had some issues because I had combined several filters in one function. Now I have a separate function for each filter. Thanks again, you helped me a lot.
Thank you for your answer. I removed the callback, but to do so had to use a boolean variable ($done) to check if the function had been executed and put the remove_filter command outside the filter function (if ($done) remove_filter…). First, I tried to put the remove_filter command directly inside the filter function, before the return statement. Then the removal worked, but the filter itself didn’t work anymore.