Put it in functions.php or at the top of the header.php in your theme. What I suspect is that the wp_title() method in header.php is already executed by the time your add_filter() is called.
Related Posts:
- Filter the blog title displayed in the header
- “Maximum function nesting level of ‘100’ reached” after adding a new filter
- Filter get_the_title to remove certain characters?
- Remove the first 5 characters of the_title and orderby that
- How to display custom seo title before the loop?
- Custom field in title
- How to make a image-size selected by default in Media upload – WP v3.5
- Apply class to every paragraph that holds image?
- Remove “Insert from URL” link in Media upload – WP 3.5
- static variable loop not working in WordPress
- How to change the wp-login.php page title?
- adding a filter to a shortcode?
- Hide custom image sizes from media library
- Set media upload attachment link to none and hide it in WP v3.5
- How to set custom cookies before output
- How to count the length of a post title?
- Permanently remove first image from posts
- Change the footer text on the login page
- How can I hook into and edit the text of a wp_nav_menu tag?
- Rename image uploads replacing “width” and “height” in filename with “medium”, “large”, “small”
- add_filter to post-gallery and remove all ‘s?
- Rename image uploads with width in filename
- How to make an meta_query optional?
- How to overwrite youtube embed?
- Rewriting search and pagination base
- Check if page parent has certain template
- How to remove “out of stock” variation options from size dropdown in woocommerce?
- Change comments form title on a page by page basis
- Display only text to WordPress loop without loosing the text formatting
- Remove class that has been added by parent theme
- Blank on static home page?
- append PHP function to the_content
- String replace WordPress Site Title
- How do I know what variables are passed in a filter/action and what their meaning is?
- Find variables available at a given hook
- wp_get_attachment_url filter won’t accept two arguments
- body_class filter – Is there a better way to write this code?
- Why do filters/actions require an argument count?
- How to add Shortcode (font awesome) in widget title?
- Filter link to existing content suggestion
- Getting my head round WordPress filter
- Customized title tag for each page in pagination?
- How To Change The Html of Products filtration sidebar in Woocommerce?
- How to filter out post type meta?
- Woocommerce filter cart and category specific quantity [closed]
- How to set a custom path, for ajax image upload folder in admin?
- Browser title script ignoring is_page /else conditional [closed]
- Blank space at beginning of tag?
- get_page_by_title with an apostrophe in variable
- Wrap First Character after in a tag
- Get posts with at least one category in common with current post?
- WooCommerce: Add Payment Gateway Field to Webhooks [closed]
- How to use return in my custom function instead of echo
- When using the_author hook, how can I determine the PHP file that generates each call to `the_author()`?
- How to call function at the bottom of post using plugin?
- Locating Global Variables
- WordPress php filter admin_body_class not working
- Set post title based on first h2 element in the content section
- Problem adding class to body_class
- Run a filter when a walker runs
- An extra ‘ is displayed in the title
- Combine two filters into a single call
- Remove a filter added by a plugin
- Change the site tagline (or similar) based on current page
- Handling Body class based on Template
- Get_avatar filter?
- WooCommerce Related Products by Attribute
- Custom filter in admin edit custom post type responding with invalid post type?
- Add a class to the anchor tag on HTML5 gallery
- Nesting if statements to echo only one string based on what tag was filtered?
- How to properly loop through these external URLs to get them into the sitemap using this hook
- Input type search in Menu
- Part of title duplicating but not sure how to remove from code – help?
- add_action shortcut?
- Is it acceptable to treat a filter like an action?
- How can I remove a function that has been added to wordpress with add_filter?
- How to control WordPress image metadata (using Imagick)?
- Edit incorrect password message WordPress
- How do I add custom bulk actions to multiple custom post types?
- Add data attribute to each li in menu
- Show prices with tax in Woocommerce Mini Cart [closed]
- Ajax category filtering products default show all
- Add a specific part of current category page url to shortcode
- Why does my callback function not work with this custom filter hook?
- Contact Fom 7 – how to add custom HTML inside span.wpcf7-form-control-wrap AND IMMEDIATELY AFTER input.wpcf7-form-control?
- Removing “wpautop” (auto tags) only on certain pages?
- Applying A Category to Existing Posts Where Page Title Matches Regex
- Add filter when image is uploaded?
- Remove a div from RSS feed
- Print last modified date only on posts
- How to add an arrow to menu items has submenus
- WordPress Gravatar filter is removing my custom attributes
- Generating an nonce for Content Security Policy and all scripts – How to make it match/persist for each page load?
- Change title only in dynamic page
- Unique icons next to each WordPress menu item
- Display custom post type title as text if post thumbnail is not available
- Change tinyMCE editor to allow marked content when pasting from Word
- Problem with login form
- Alter required message using comment form api
- How to debug this search & replace strings snippet?