There’s a filter for that:
function wpse_alter_title( $title, $id )
{
// $id = $post->ID;
// alter the title here
return $title;
}
If you want to alter the “Protected” and “Private” titles, then you need other filters:
// Preserve the "%s" - else the title will be removed.
function wpse_alter_protected_title_format( $title )
{
return __( 'Protected: %s' );
}
function wpse_alter_private_title_format( $title )
{
return __( 'Private: %s' );
}
Last but not least, you must add your filter callbacks early enough.
function wpse_load_alter_title()
{
add_filter( 'the_title', 'wpse_alter_title', 20, 2 );
add_filter( 'protected_title_format', 'wpse_alter_protected_title_format' );
add_filter( 'private_title_format', 'wpse_alter_private_title_format' );
}
add_action( 'init', 'wpse_load_alter_title' );
Related Posts:
- Changing title of a page dynamically from within a plugin
- What is the proper filter to add html to a post / page title?
- How to add terms to a post depending on its title?
- WordPress Plugin Boilerplate – add_action hook in static “activate” function
- Capitalize All Titles and Headlines in Chicago Style
- How can I list recent posts excerpts?
- How to append to title via functions.php for auto-posting plugin [duplicate]
- Init plugin again after ajax call finish
- Which filter affects the ‘entry-title’ post class
- how to add text to posts from tags
- add_action in a custom plugin
- Plugin init hook fires repeatedly
- Show Sitename on Yoast SEO Title tag [closed]
- Basic function call on init failing
- Insert Message before content of after title
- How to customize a title by passing query string?
- Customizing Titles on the Fly with Code
- Site shows URL instead of “meta title” after deleted few plugins (not any SEO plugin was deleted)
- Can i use init hook for API purpose?
- If post exists in the database – each time goes on `else`
- Developing plugin, where to place action hooks etc?
- When/where would want to attach other classes to the base class in a WordPress plugin?
- How to make the first letter of a post title uppercase, in a plugin?
- API calls on plugin activation or init?
- How to execute init or woocommerce_init only for checkout page
- How to view Plugin Manager in Notepad++
- Use Notepad++ as HEX-Editor
- fix the error : Plugin with id ‘com.android.application’ not found
- Best collection of code for your 'functions.php' file [closed]
- Tips for using WordPress as a CMS? [closed]
- Adding a Taxonomy Filter to Admin List for a Custom Post Type?
- Updates for a private plugin?
- Uninstall, Activate, Deactivate a plugin: typical features & how-to
- Best way to initiate a class in a WP plugin?
- Which banner plugin is this? [closed]
- Upgrade 4.5.2 to 4.5.3 deleting row in wp_options table
- Woocommerce – adding variations to variations [closed]
- Best way to include wp-config.php
- similar of my posts in all over the internet sites and blogs [closed]
- Between functions.php (theme), widgets, and plugins, which is loaded first?
- Create custom page templates with plugins?
- Custom Post Type Templates from Plugin Folder?
- to perform the requested action wordpress needs to access your web server. please enter your ftp
- Disable update notification for individual plugins
- Passing a parameter to filter and action functions
- Do deactivated plugins slow down a WordPress site?
- What security concerns should I have when setting FS_METHOD to “direct” in wp-config?
- How do you debug plugins?
- How to structure a plugin
- What’s the preferred method of writing AJAX-enabled plugins?
- Get Product id from order id in Woocommerce [closed]
- Add multiple plugin directories
- What are the differences between WPINC and ABSPATH?
- Translate a plugin using .po .mo files
- Best way to overide plugin CSS?
- How to add a shortcode button to the TinyMCE editor?
- Where do I put the code snippets I found here or somewhere else on the web?
- Is there a plugin that provides a stackoverflow style editor for wordpress? [closed]
- Get a list of all registered actions
- How can I force a file download in the WordPress backend?
- What Plugins Demonstrate Great WP Plugin Development? [closed]
- How to implement a customizable free OpenID authentication?
- Should all plugins be encapsulated in a Class?
- How to check if the product is in a certain category on a single-product.php in Woocommerce?
- How can I stop WordPress from prompting me to enter FTP information when doing updates?
- In what order does WordPress load plugin files?
- What Features would you Most Like to See Added to WordPress? [closed]
- Given the ID of a product in woocommerce, how can I get its URL?
- Adding Additional Attributes in Script Tag for 3rd party JS
- How can I edit post data before it is saved?
- Manually set global $post vars with an ID, in order to use template tags
- is_plugin_active function doesn’t exist
- How To Activate Plugins via Code?
- Disable plugin / plugin action via theme
- ‘Global’ settings page for multisite plugin
- Activate a plugin through PHPMyAdmin or FTP?
- What Are Security Best Practices for WordPress Plugins and Themes? [closed]
- How can I use WordPress functions in my stylesheet?
- How do I show data from gravity forms in my template? [closed]
- Show a different number of posts per page depending on context (e.g., homepage, search, archive)
- Creating a plugin with dependencies
- How can I make add_image_size() crop from the top?
- Implementing a CrunchBase.com Clone using WordPress?
- Difference between add_filter and apply_filters
- Add Google Analytics manually, or use a plug-in?
- How to enable suggested edits?
- Delete WordPress plugin Repository
- Disable email notification after change of password
- Custom pages with plugin
- How to change a user’s password programatically
- How to catch/what to do with a WP Error Object
- How can I see all the actions attached to an “add_action” hook?
- Proper Way to Modify Plugin
- wp.media.view.ImageDetails – Save settings as HTML5 data-* attributes for image
- Are WordPress Plugins essential?
- wordpress on localhost lamp doesn’t let me install plugins
- WP Rest API: details of latest post including featured media url in one request?
- Hide prices and checkout functionality in woocommerce
- Prompted for FTP details even with FS_DIRECT set to true
- what is the correct way to update a plugin via tortoise svn to the repository?