The problem is global $post.
As @Pieter suggested global $post object can be alter anytime with some other plugin or code. Menu items are effected because global $post does not contain the correct object.
Instead of $post, the_title filter also provide you ID of current post in action, so use it in this way
function append_album_review_to_title( $title, $id ) {
if ( get_post_type( $id ) == 'album_review' ){
return 'Album Review: ' . $title;
} else {
return $title;
}
}
add_filter('the_title', 'append_album_review_to_title', 10, 2);
Related Posts:
- Passing a parameter to filter and action functions
- Get a list of all registered actions
- How can I edit post data before it is saved?
- Where is the best place to use add_filter
- How to only hook on Single.php after content?
- Use external link in the add sub menu
- Very stubborn wp_register_script / add_action vs remove
- do_action and hook methods
- How to filter content post only on save
- Filter or action hook to insert content on admin pages before tag
- What is the purpose of $merged_filters?
- How do action and filter hooks understand where to look for the core function that we hooked our function to them
- How to check current user before all actions and filters?
- Get Time Taken By Each Action Hook in WordPress
- Plugin developer automated documentation
- Is there a hook to Intercept al urls from a webpage and redirect to a page
- WordPress user account activation
- External Script Using WP – Hooks / Actions Not Working?
- Is there a way to figure out which action/filter invoked a function?
- Using add_action before add_filter on a plugin?
- remove_action not removing add_action from constructor
- Editing wp-config.php
- How to use add_action for multiple instances of the same class
- How to hook into action/filter call
- How to append new form elements in “Add New” form of Users in WordPress admin panel?
- Edit post image attributes on fly?
- How to Unhook actions/filters in within Class in plugin
- Nested Actions and Filters
- Use action, filter, or hook to append HTML to WordPress plugin function
- Remove action added in plugin class from theme
- Help needed with woocommerce (wc stripe) filter
- What action or filter can I use to change all the html returned from server for a page?
- Why can’t I shove an instance of a class into a variable from a do_action hook?
- Passing a parameter to filter and action functions
- change output location of plugin function using a custom hook
- Filter for modifying image on upload
- Which filters or actions involve with index page for plugin?
- add query string to all pages after user logged in
- Which action/filter can i use for a Member Plugin [closed]
- How to customize WP_Error (REST JWT authentication plugin) [closed]
- What characters are allowed as a shortcode tag and how should they be sanitized?
- What is the ‘admin_action_’ . $_REQUEST[‘action’] hook used for?
- Hide WordPress Plugin Deactivation Links
- Is it possible to add an action to the currently running action?
- ElasticPress how to Include Meta to the mapping?
- Action on post publish
- How to add inline css/js inside a shortcode
- How to prevent action in ajax request, when in admin side?
- Can I use a method from an existing plugin as an action hook?
- Reposition Woocommerce Message
- Detect when any plugin is activated or deactivated
- How to modify shortcode attributes with data from current post
- Is there a filter for get_post_custom()?
- How to append to title via functions.php for auto-posting plugin [duplicate]
- Any hook for pre-plugin-update -either bulk or single plugin update
- wordpress plugin is not activating from widget
- When to load auto-login code?
- Modifying the comments section through a plugin regardless of theme
- Passing an array from shortcode-function to filter-function
- Removing an action from wp_footer called in a class that’s inside a bigger class
- How to change the name of the “edit my profile” link in the WordPress admin backend
- add_filter doesn’t work
- add_action in a custom plugin
- Template filter for custom taxonomy terms
- Add action to fire when a published post is updated
- Run a plugin just ‘once’ per page reload
- Override a Plugin Function
- How to remove products-links after the product title using remove_action
- Can I filter a function created by a theme or a plugin?
- wp_ajax action responds with 0
- Custom CSS not being added by plugin
- Looking for a filter to modify the months
- I cannot include a file in my plugin settings page
- What’s the best way to echo out a filter variable?
- How to convert Currency from USD to other IP Based currency in Php function
- How i remove specific script from header?
- How to remove default action from a plugin?
- taxonomy_template filter not working on pagination [duplicate]
- 500 Internal server error wp_handle_upload_prefilter
- Using Filters to modify contect – DB query results alwats appear fist
- Get post content inside plugin class method
- Ajax call to php function doesn’t work PHP code
- Frontend AJAX Request causes Error: ‘Call to undefined function add_action’
- Creating Admin Submenu Page via Class Method
- WordPress Add advertising ads befor and after content with periority [closed]
- Edit plugin filter
- Am I using an action hook correctly?
- AJAX login without a plugin does not work. when add a action to function.php
- How do i get all author posts on custom post type list
- Remove action working on functions.php but not in a plugin. Why?
- How to filter a a variable in a plugin’s function?
- Retrive images from the_content()
- passing ‘&’ in return function of add_filter
- Filter the HTML content of plugin
- My wp_update_nav_menu action is firing twice
- Unable to pass arguments from plugin form to filter hook using ajax, the data is transferring via ajax but unable to pass as arguments in filter hooks
- WordPress REST API filter on blank custom ACF
- Brands Filter Not Working For On Sale Products
- Removing filters with arguments set in a class
- How to display title, description etc in block images?