You can’t use get_the_ID()
when you are not in the loop (eg. in nav menus). Fortunately, the the_title
filter comes with the post ID in an extra argument.
Change your code to this, to make it work in all places:
function mealingua_title_filter($title, $post_id) {
#some stuff
if (is_front_page() OR is_single() OR is_page()) {
return '<span class="mealingua_title_container_' . $post_id . ' mealingua_title_container">' . $title . '</span>';
} else {
return $title;
}
}
add_filter('the_title', 'mealingua_title_filter', 10, 2);
Related Posts:
- WooCommerce store with ~30,000 products [closed]
- Uncaught Error: Call to undefined function wp_generate_attachment_metadata() @ wp-cron
- Using require_once in a Plugin?
- Being notified when some YouTube video in some post becomes unavailable
- How to call “page specific menu items” in template [closed]
- Override dynamic_sidebar() in plugin?
- How to update WordPress plugin readme.txt description page without triggering a plugin update?
- publish_post hook isn’t working for scheduled posts
- Creating a theme option page?
- Add post thumbnail from external image with plugin
- Why is this custom taxonomy showing in the database?
- Where is the source code that makes the “all” array grabs filters in the $wp_filter?
- How can I change plugin to give access to editor user role?
- Is it possible to add an action to the currently running action?
- How do I get slug of all active plugins programmatically?
- Only execute jQuery function(on document ready) on the page has shortcode from plugin [duplicate]
- unzip a folder on specific location and delete the zip file
- Change settings of get_post_type_object
- Check if User exists in WordPress Multisite
- Embed a Google Sheet as you view it in a separate tab?
- Duplicate posts when posting nulls in records in phpMyAdmin [closed]
- Plugin version is not showing up in wordpress.org plugin directory
- Saving changes in wp_editor
- How can I check if on specific plugin generated page or child
- Removing customise fields during plugin uninstallation
- plugin class inheritance. cannot change variable
- Transition from the pro version to the free version of the plugin
- There is any way to remove post-format filter? [closed]
- Search for categories
- Best way to initiate a class in a WP plugin?
- Trying to fix form resubmition with PRG (Getting error: Cannot modify header information – headers already sent by)
- Retrieving Meta from Image Attachment
- Why this function not working for install database on plugin activation
- The Hook registration_errors was not called
- Problems With WP Bannarize Plugin [closed]
- How to create a child/addon plugin
- How to secure the release of WordPress plugins / avoid copying plugins?
- What happens if I don’t update my plugins?
- Hide certain widgets from specific user roles in admin
- how to force tag page layout to use same as search layout?
- Delay JavaScript files from loading
- WordPress Users authentication with Java Application
- remove_action not removing add_action from constructor
- Is there a way to make the main page only display a brief description of the full article?
- how to make wordpress plugin from PersianWebToolkit? [closed]
- Limit WP code scope into plugin
- WordPress custom plugin that uses woocommerce enabled payment gateway for payment [closed]
- Execute a function when the entire page is displayed
- Is there any way to inject text onto pages?
- WordPress as heavily personalized content management portal, and somewhat like dropbox [closed]
- Plugin that lets visitors Like a post (not facebook) and stores likes in custom meta?
- Cannot read properties of undefined (reading ‘firstChild’) using photoswipe in product page
- Multisite Change from domain.com to sub.newdomain.com
- “Welcome to WordPress” Plugin Required Error
- Find Plugin by file name
- Creating an admin button that when clicked shows a popup form
- How to list datas from database in a topic?
- Add an action based on custom post meta field
- How to hide an option from dropdown in filter module
- Downloading a file
- Profiling the initial PHP file, anyone, that get like 10 seconds to load
- How use wp_insert_post and add og:custom tags?
- Remove Keywords From Webpage But Still Use for SEO
- how to create user profile pages and display them based on users roles
- How to change “Read More” text?
- How to use wp_editor and save its data in wp_posts table
- WordPress database problem wp_posts, primary key
- Auto trigger of popup
- My WordPress activation hook isn’t working
- Woocommerce – Change variations output
- WordPress Plugin PHP Not Calling Function
- how to show the tables of my plugin in the export tab of WordPress?
- how do i fixe Page Builder on a custom page?
- WordPress ajax error 400 bad request for sending data to remote site [duplicate]
- Do_shortcode before send email content
- wp_enqueue_scrpts seems not to get called
- How to Create Custom Dashboard for my Laundry Website?
- Warning: Illegal offset type in /var/www/html/wp-includes/option.php on line 1924
- Get plugin to background of page
- How to create a WordPress sandbox on a live server for website development?
- What is a good way to test that plugin upgrades have completed properly?
- get post excerpt by query
- Advanced Custom Fields (ACF) Plugin – Random Image in Sidebar
- Include paths and functions for external scripts
- Postal address auto-complete on profile page
- Deleted plugins displays error message
- Remove the ‘Press This’ Tool
- __FILE__ in WordPress plugins
- Looking for a related post plugin which slides-in like the one at inc.com does [closed]
- which is this plugin ? [closed]
- Woocommerce Product Add-ons – Auto-select first option
- Sync roles across several plugins
- How to write a specific url for only single page in wordpress?
- Identifying Plugins Based on Tables [closed]
- manage_{taxonomy}_custom_column not working
- I want to set a different banner for each product in the woocommerce plugin on my wordpress site
- I want create woocommerec match products columns
- How to be Variables and options must be escaped when echo’d?
- Remove embed url for internal links
- WordPress Custom Page Blog Template Pagination Problem (Pagination Not Displaying)