Filters always return something, they’re not actions, they take something in, modify it, then return it, but your filter does neither.
As a result, PHP declares that it returned null, and the next filter along recieves null as the post content.
For example, this filter appends the word “Hey!” to the end of the content:
add_filter( 'the_content', function ( $content ) {
return $content . 'Hey!';
} );
So here are things you need to keep in mind:
- filters get called a lot, do not do heavy work in filters
- filters are for filtering, you take the first parameter, do things to it, then return it
- filters always return something
- do not
echostuff out on a filter, you’re meant toreturnthe full value with your modifications applied
Related Posts:
- Delete tables from database when deleting plugin
- WordPress sharding: which multi-DB plugin to use?
- Simple form that saves to database
- How to run Two WordPress blogs with different themes and with single database and same content
- Plugins or Tutorials for displaying data from SQL-db on WP-page? [closed]
- How do I check what plugins are enabled via the database?
- Disallow a user to post in certain categories
- Can I explicitly specify ENGINE=InnoDB in WordPress?
- Create custom column in post table in wordpress
- Custom database or Custom Post Types?
- How to update widget_text in the wp_options table
- Get the last post ID
- Add agenda items and notifications
- How to count number of records found in a database table?
- prefix table and plugins
- Taking WordPress table prefixes into account
- Changing BIGINT to INT
- WordPress register_activation_hook table creation not working
- How to add Edit | Delete button on rows?
- The plugin generated x characters of unexpected output, $wpdb not defined
- clean wp_options table unused rows
- Storing Email Account Passwords for SMTP Mailing for a WordPress Plugin
- Placement of Code in Plugin for hooking `save_post`
- If I delete plugins via FTP are settings kept in DB?
- Get total number of comment of the posts written by an author
- How to write one comment and publish on every post using database or plugin?
- Make id column as AUTO INCREMENT on plugin activation
- What kind of data is that?
- Saving Custom Post types and fields to a custom table
- Where does WordPress store plugin (enabled/disabled) status for multisite?
- When to use action hooks and plugins
- How to create custom tables in WordPress using my own plugin?
- How to access data in wordpress database externally using php
- custom user tables supported in SharDB plugin?
- DROP TABLE with uninstall hook not working
- How to check if tables in WordPress still exists after activations
- how to oauth1 Wp plug-in revoke/reset.?
- Keep a post copy when this one is updated – issue
- How can I perform high-level database merging for WordPress within continues delivery?
- How to inform the user that the save was not successful?
- WordPress Backend HA (Automatic failover)
- Migrating to WordPress Recipe Plugin and Some SQL Issues
- WordPress Integration with Google Groups
- wp_editor content in plugin options page
- Multiple instance of data in plugin custom database table on plugin activation
- WordPress plugin creating database in localhost but not on real host
- “Master” WordPress Multisite – Database Sync
- Is it necessary to auto delete my WP plugin database tables when users deactivate/delete my plugin?
- Does deleting a Plugin via the WordPress admin ‘completely’ remove the code?
- How do i edit the plugin files in DataBase via phpMyAdmin?
- How to insert and call new data in wordpress website database through a plugin
- WPDB: Update table
- Separate database for a wordpress plugin
- How to keep variable `$post` to using in another file
- Making my plugin create a page?
- Add some fileds to the wp_posts table
- Best/Correct way to add an option to a category
- Always get creating a new table with foreign key
- How to do database for download stats?
- What is the WordPress approach to custom data?
- How retreive saved data from gravity forms in my template?
- DB Query not working in Plugin
- Where do plugin variables live in the db?
- Plugin: connect to external database without showing password
- How to access the WordPress DB from a plugin file
- Storing Form data in a different database
- How to add a custom form to a plugin’s setting page
- update_option creates an option, which empties on a blog reload
- More than one WordPress site using the same database – how to disable plugin for one site?
- Bookmarking custom template pages which all have the same page ID
- What database state changes happen after a post is manually “updated” with no changes?
- Bulk Edit Media Library alt, caption, image names
- Can i stream data to a custom_post_type?
- Cant create table on plugin activation
- How do I add a medium to the WordPress database with my own plugin?
- Get Shortcode output to database for static post_content
- Moving a few select DB tables to a new WP instance
- How wordpress handle urls present in db for external wp-content directory
- Using Filters to modify contect – DB query results alwats appear fist
- On save_post need to wp_insert_post and save partent post id to child post and child post id to parent post
- Enable plugins that are “not supported”
- Many to many relationship for variable products
- Is it a good practice to use wordpress database to store pages contents which loading to page dynamically?
- Where do the section input fields values are stored in database
- My plugin can’t see my files
- How to create a custom page for unrelated database?
- Show a table from data submitted by a form from a user
- How to save information related to post in database?
- RSS Feed has no Items (Possible Plugins Conflict)
- A plugin is giving me “You do not have sufficient permissions to access this page.” error
- How to find an option in the database?
- wpdb get_var is not returning any result (verified mysql query returns only one value)
- Managing database tables in WordPress multisite
- Creating fields in the database
- Allow users to enter and edit data in one-to-many configuration
- Updating WordPress [closed]
- Save post to category with gravity forms (post_data) [closed]
- User register hook can’t access form request
- Fragmented Static Conversion of WordPress Pages
- plugin doesn’t retrieve data from database