Is it bad practice to add a filter within a filter for wordpress?

Say for example, You only want this filter to run within the callback function of another filter, and then remove said filter before the function finishes, so that the filter does not affect the site outside of this function.

  • Not necessarily, but it is sort of a messy workaround. Do you have an example? Commented Apr 11, 2023 at 13:16
  • The example I was thinking of when I wrote this was having the filter wp_mail_content_type within wp_new_user_notification_email to convert the content type within the header to HTML from plain text, but there was a better way of doing it that I ended up using. I was curious if it was generally bad practice to put a filter within a filter even after the fact, so I asked that here anyways. @JacobPeattie Commented Apr 12, 2023 at 18:24


Your Answer

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

Browse other questions tagged or ask your own question.