You’re not filtering anything, that’s what’s missing and what the error is complaining about. Filters accept an input value and return something.
$original_value="foo";
$filtered_value = apply_filters( 'wpd_filter_function', $original_value );
The function should then accept $original_value
as an argument and return
some value, which is what you’ll get in $filtered_value
.
What you have in your code would be more appropriate as an action:
function wpse203948_header_cart(){
echo 'something';
}
add_action( 'wpse203948_header_cart', 'wpse203948_header_cart' );
// applying it
do_action( 'wpse203948_header_cart' );
Related Posts:
- How do filters and hooks really work in PHP
- Trouble understanding apply_filters()
- How would one modify the filtering Gutenberg applies to pasted content?
- Gutenberg: Is there a way to know if current block is inside InnerBlocks?
- How to reorder billing fields in WooCommerce Checkout template? [closed]
- How to add a custom CSS class to core blocks in Gutenberg editor?
- Filter translations (gettext strings) on specific admin pages
- Is it possible to use object in add_action?
- Filter hook before create order WooCommerce
- How to auto-translate custom user roles?
- add_filter for specific pages
- How to add attribute to output with wp_video_shortcode add_filter
- How to override the email function by using filters? [closed]
- Remove WPML’s home_url filter
- Change default settings used by gallery shortcode
- PHP5, Inheritance, Singleton – action & filter hook limitations
- Please explain me what the do_action does
- Add ‘if exists’ to filter
- how to remove filter from wordpress shortcode output
- Change email from and display name with a filter action
- How to get current action?
- How to check if “media_send_to_editor” is audio?
- Changing Order of Filters
- Please help me through this example with a filter to understand how they work
- how to change appearence of the content of default post list columns?
- Filter custom post types in archive
- WordPress tag cloud add more links
- Use safety filters even if after applied intval?
- How can I filter block registration based on post-type? (Block alignment settings)
- wp_insert_post_data filter not working correctly after upgrade to WordPress 5
- Modify site URL via functions.php of a theme
- Yoast SEO hooks overriding themselves
- Passing variable from child theme to parent theme
- Question about how do wordpress filters/actions work
- How to center oEmbedded content
- How to change the order (priority) of registered filters (or actions) (e.g. for the_content)?
- Add Sortable Column For All Post Types
- How to take options from form fields and turn them in to links?
- How add a group by to the query used by the media library?
- How to properly modify WP Vary or any existing headers?
- how to use force_filtered_html_on_import in add_filter?
- Custom wp_query time filter on meta_value
- Adding a filter to comments_template
- How to customize category_description()?
- Add Bootstrap Classes to Recent Posts Widget
- Add filter to get_posts
- How can I output all apply_filters and do_action?
- Override has_post_thumbnail function
- Is it possible to override the default Gallery Settings form?
- remove_action: how to access to a method in an child class?
- Set default value for “Additional CSS class(es)” for specific block types
- Filtering a list of objects with ‘OR’ on the same field
- Excerpt is being added above the content, but it should be after it
- WordPress add script with custom type (x-jquery-tmpl)
- Woocomemrce order and registration fileds to UPPERCASE
- How to filter bbPress replies (content)?
- Change login CSS
- How to redirect non-logged in users to login with post_password_required()
- How to add nonce tag to inline script for CSP
- Filter content for get_the_content()
- Change user nicename without sanitize
- How to override include_once pointed file using add_filter?
- How to strip out javascript in wp_posts `post_content`
- WordPress removing slashes from shortcode output
- Register new user, assign custom role then send email
- What would cause the gettext filter to not work for a given text domain?
- pre_get_posts to hide everywhere posts from “Archive” category
- Strip $before & $after strings from a page title
- How to remove shortcode(s) from WYSIWYG Page editor for Non Admins
- What is the action or filter for adding information under the Permalink in Edit Post/Page?
- add after content don’t work
- Adding a filter to related posts not working
- need correction with a snippet in functions.php [closed]
- conditional search
- output custom Posts on a Page
- Sql query does not work well
- WordPress Gutenberg core/heading block (wp-block-heading)
- add_action with associative array
- Why does wp_die() not work when inside a namespace?
- Apply pre_get_posts filter in a certain moment (just for a particular block of posts)
- Set post featured image to author image
- How to Change the WordPress Locale with the ‘locale’ Filter?
- meta box loop problem with a search filter
- How to make the show as a button?
- Modify Default URL for /wp-includes/js/wp-emoji.js?ver=4.6.1
- Read More in the actual excerpt
- WP REST API v2. filters doesn’t work
- Is it possible to include the add_filter() function within a shortcode function
- Activate short codes for all post queries?
- Save something to global var in add_filter
- filter on the_content stopped working when I updated to WP 3.6.1
- Replace Paid Shipping Method With Free Shipping Method WooCommerce [duplicate]
- Wrapping Featured Image on Add/Edit Page in div?
- Clean/filter HTML inserted to post content by XML RPC
- how to localize the number of wordpress post views?
- Is it possible to make get variable out of filter in Class?
- NextGEN Gallery: Adding drop-down menu widget to gallery view without modifying plugin code [closed]
- How to elect position of new item output in a dropdown when using add_filter
- Filter a custom post type by custom field in admin
- Search and Filter Using Custom Post Type, Custom Taxonomy, and Advanced Custom Fields