How to apply filter

Just put the code inside functions.php that lives in your theme folder:

wp-content/themes/[your-active-theme-name]/functions.php