Usually I remove the filter, then add it back on afterwards;
function _my_custom_option( $option )
{
remove_filter( 'pre_option_name', '_my_custom_option' );
// do what you like with $option
add_filter( 'pre_option_name', '_my_custom_option' );
return $option;
}
add_filter( 'pre_option_name', '_my_custom_option' );
Related Posts:
- Is there a wildcard/catchall filter hook?
- Plugin options, presets and filters : can you help me improve my workflow?
- How do I safely force get_theme_mod() to use a defined get_option(“stylesheet”) value?
- Use alternative front page if cookie is set
- Is it possible to dynamically change the “page_for_posts” option?
- How to filter users on admin users page by custom meta field?
- Where is the proper place to add a filter for pre_get_table_charset?
- post_row_actions filter is not working while update post using quick edit
- WordPress Rest filter for custom taxonomy gets applied to the admin area
- add class to internal links in content
- Am I using the right hook for removing quicktags on the admin TinyMCE?
- Help debugging PHP filter for wordpress [closed]
- About Hooks and Filters
- How to always display a specific post from the search result first
- How to link current user to their author page through shortcodes
- filter title from shortcode
- Add a Span Around a Product Title in WooCommerce [closed]
- Taxonomy Custom Column – ‘manage_{TAXONOMY}_custom_column’ filter only passing 2 arguments
- How to get list of all hooks of current theme / plugin?
- get_query stops working after post filter
- How to filter into post meta data before saving
- Adding custom column to comments admin panel?
- Filter out some plugin action in wp head / wp_footer
- Can you use add_filter() inside other function?
- is there a specific place where add_filter must be placed?
- add_filter() function misunderstanding
- How to make a widget expand wider than the column width when editing its settings in the admin
- Apply the_content filter, but prevent other hooked actions
- Filter my args by the post 1st letter
- Can the wp_filter object hold multiple values with the same key
- apply_filters/do_action tag characters limit
- Adding Filter to Homepage only
- the_excerpt filter with an empty excerpt
- Add Defer Attributes to WordPress Scripts with consistent versioning
- How to stop wrapping comments in P tag
- Remove CSS & JS files from WordPress Main Page For Increase Pagespeed?
- String regex match replace for role ‘contributor’ only
- In need of a content replace filter for posts in a specific wordpress category
- Can plugins that filter post contents work on posts from Word 2007?
- html tags in gettext hook get escaped
- How to filter post content and force every link () made in blocks to return urldecode() with readable value?
- Set default terms for new posts / CPTs
- Better extend a class or use add filter/action hooks?
- Link to Shop-Filter with .current-menu-item
- Adding a Clone link to product attributes – post_row_actions() filter, or how to override a Class question
- wp_upload_bits Upload Specific Sizes Only
- Remove posts inside pre_get_posts using a custom query
- Remove / Hide Attachment Display Settings in Add Media popup / dialog
- how to customize rss feed tags using hooks?
- Woocommerce “added to cart” message on main(home) page
- Why does adding a filter to ‘the_title’ break the server?
- Redirect to another page using contact form 7? [closed]
- Is it possible to apply filter to meta key value when querying posts?
- Add filter for specific post type only
- Avoid user registrations with specific email provider
- Should I remove_filter in order to replace a filter?
- Change custom post type GUID in RSS
- How can I specify the post status of an untrashed post?
- filter hook to load a different post/page on current post/page
- How would I be able to use a font awesome icon as a user’s avatar?
- Add something after a filter
- Rewrite rule and display of post
- add_filter the_content doesn’t work
- Redirect to woocommerce checkout after adding to cart – item already in cart
- Passing variable from child theme function to parent theme filter
- `authenticate` filter never gets called
- paginate_links() Change the order of links
- How to disable a wp filter in a certain admin panel page
- Is there a filter to programmatically change the HTML tab switching output of the page editor?
- Why does admin_body_class not work?
- post_orderby filter breaks function
- Disable Remember Me in Login Form
- How do I add a line break to a string that is output by PHP?
- Counting a WP_Post Object value in an arary, using a filter?
- List all categories that have results in a query
- Distinguish between page and post in function
- Display posts from today and future in Elementor ‘posts widget’
- Right filter for rewriting page statuscode
- Changing title using filter not working with argument
- Archive Widget – Count only parent posts
- How to filter page title for certain page?
- Displaying posts on a page that have been assigned a value in a database
- Replace Text with hyperlinks
- adding an action inside if condition not working
- Adding filter to an specific page/site direction
- How to filter wp_get_recent_posts() to only posts that have thumbnails?
- Change add_filter based on Ajax
- How to check which submission button was clicked?
- check, if any “add_action” function contains string XXXXXXXXX
- remove_action conditionally for Custom Post Type – not working
- wp_get_attachment_link filter not working
- How would I remove an inline googleAPI font script in the the parent theme header.php?
- Add Default WordPress Formatting To Data From External SQL Tables?
- Joining tables not working in the post editor page
- Getting entry ID from frm_email_message filter in formidable
- Auto append text after the title?
- Is there a hook or filter that adds a button to the left of the search box?
- Filter and manipulate the get_current_user() function
- add_filter(‘the_content’, ‘method’) does not trigger my custom method
- Limit total tags in the_content