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
echo
stuff out on a filter, you’re meant toreturn
the full value with your modifications applied
Related Posts:
- Delete tables from database when deleting plugin
- 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?
- 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
- 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?
- 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.?
- 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
- Is it necessary to auto delete my WP plugin database tables when users deactivate/delete my plugin?
- 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
- Issue running db create table query from static method
- Problem of encoding characters (apostrophes) in my posts publications
- Separate database for a wordpress plugin
- Is there a rule for wordpress plugins developers to not do any database changes upon update?
- How to keep variable `$post` to using in another file
- Making my plugin create a page?
- Add some fileds to the wp_posts table
- 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?
- Comment “like” problem – “users who like this” avatar linking to current user profile instead of “liker’s” profile
- How to relate 3 wordpress components with each other (Create database relationships)
- How can I store data from custom fields to custom tables?
- How to access the WordPress DB from a plugin file
- How to display results from a data table with an encrypted user id?
- How to add a custom form to a plugin’s setting page
- update_option creates an option, which empties on a blog reload
- add_action for publish_post doesn’t work
- Bookmarking custom template pages which all have the same page ID
- Bulk Edit Media Library alt, caption, image names
- Cant create table on plugin activation
- Optimise wordpress database using SQL after deleting registered images from Media Folder
- How to implement data residency in my WordPress site
- Moving a few select DB tables to a new WP instance
- WordPress database problem wp_posts, primary key
- How to allow URL with filename & extension in wordpress?
- 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
- PHP message: WordPress database error Deadlock found when trying to get lock
- 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?
- using wordpress login details for other website / application / forum?
- Where do the section input fields values are stored in database
- how to create database to use it in wordpress website?
- How to create a custom page for unrelated database?
- 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)
- Is there a plugin that will override the “Error establishing a database connection” message? [closed]
- Get the url of attachments from the post?
- Create New Admin Menu Section – Like how custom post type works, in a way
- 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]
- Shortcode returning specific content of a post
- How can I delete the options from DB when the plugin is deleted?
- Text Wrapping in WPDataTables
- Very slow page loads
- Form with response button after on table after submission
- Can’t save formdata in DB