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
- Apply class to every paragraph that holds image?
- How to change the wp-login.php page title?
- 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?
- 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”
- Rename image uploads with width in filename
- How to make an meta_query optional?
- Check if page parent has certain template
- How to remove “out of stock” variation options from size dropdown in woocommerce?
- wp_get_attachment_url filter won’t accept two arguments
- Why do filters/actions require an argument count?
- Filter link to existing content suggestion
- Getting my head round WordPress filter
- 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
- Get posts with at least one category in common with current post?
- 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()`?
- Locating Global Variables
- WordPress php filter admin_body_class not working
- Set post title based on first h2 element in the content section
- 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
- WooCommerce Related Products by Attribute
- Add a class to the anchor tag on HTML5 gallery
- add_action shortcut?
- How to control WordPress image metadata (using Imagick)?
- 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
- Removing “wpautop” (auto tags) only on certain pages?
- Print last modified date only on posts
- WordPress Gravatar filter is removing my custom attributes
- Change title only in dynamic page
- Display custom post type title as text if post thumbnail is not available
- How to debug this search & replace strings snippet?
- Hide Featured Image Meta Box on Editor Screen
- Add item to top of menu using a filter in functions.php
- How to make modifications only to certain elements of an HTML string on the server-side?
- Run str_replace on title and save the output to a custom field
- Echo title attribute php
- Add meta tags to a custom header
- Ajax filter button display all posts
- How to append to an array and return the results in a filter?
- woocommerce related product title length
- Custom query vars filters problem with pagination
- Filter by field with array value in ACF on WP REST API
- wrap a span tag around author’s post count
- Must filter functions receive all arguments passed to them?
- Filter wordpress posts without searching the keywords in the post content
- Variation prices breakdown only for single product page
- Test the existence of a page/article by its URL, taking in consideration the URL rewriting by filters
- Filter ‘comment_notification_text’ not working
- Remove Author Links
- How to remove get_header From all single pages in wordpress with functions.php without plugin?
- Apply function.php filter only if url not has /amp/
- Change lost password url to a mailto URL in WordPress
- How to edit post meta data before publishing the post it self wordpress?
- Multiple Tag Filtering
- Add a top bar to a wordpress theme without editing the header.php file?
- Should I set a page as “No-index” if I include it’s content within the front-Page.php via this method?
- How to change href of a Widget menu item link?
- Reload page with a different shortcode when a user selects from a dropdown
- WordPress Ajax filter: Create two loops for different output styles?
- How to disable sub menu items from being created?
- How can i style “echo apply_filters”
- Adding body class to html tag that already has language attrubutes?
- Put a span class in the shortened product title
- How to remove title tag with this filter
- str_replace not preserving whitespace
- “Page Array” displaying in title bar on Front Page
- Custom theme: adding unwanted tags in the content
- Apply filters when loading post via ajax
- Get terms of the posts with one query
- Woocommerce Price Text
- Limit Taxonomy Parents
- dynamically filter by category via sub-menu
- Display a list of users with avatar filterable with alphabets
- How to add custom checkout field in user details mail template
- Keeping the previous get value and add another value when submitted
- For each loop will not append to the_content hook
- Assign new post author IF another user in custom field on post transition
- Modify meta data before saving to database
- How to change wp-admin and wp-login urls
- How to add different menu items on different menus?
- Custom Filtering date with newsletter