You need to add the filter later:
function _add_my_filter() {
if ( is_home() OR is_sticky() )
{
add_filter( 'the_content', 'my_function' );
}
}
add_action('template_redirect', '_add_my_filter');
Related Posts:
- What process do you use for WordPress development? [closed]
- How do I create a custom role capability?
- What is the advantage of using wp_mail?
- Where to put third party PHP library?
- Add a new tab to WordPress Plugin install Listing
- Export data as CSV in back end with proper HTTP headers
- How to integrate a PHP webmail script into the backend of WordPress?
- Calling the widget id of a mult-instance widget from inside the widget?
- Do I need to call do_action in my plugin?
- Fatal error: Call to undefined function wp_mail()
- Does WordPress have an Browser Agent?
- How Do I Load My Action Earlier Enough?
- WooCommerce get Shipping Class of product from either the product id or the order after order is completed
- Dequeue script, but still use wp_localize_script to pass vars
- I can’t find where a hook is being defined in a plugin – Easy Digital Downloads
- Filter on the_content ignores shortcodes
- Can I add pages to my custom menu via script?
- Replacing WordPress menu functionality with a plugin
- Use a PHP file as action for a form in a WordPress plugin, what’s the correct way?
- Featured Image not showing in admin
- Hello dolly type plugin that allows people to add their own
- Activation hook not creating table
- Is the usage of ON DELETE CASCADE wrong or not allowed on wordpress?
- using get_option to add a different js
- Add Submenu Link in add_submenu_page That Opens in a New Window
- wpColorPicker is not a function!
- How to display non-page / post content
- WordPress Hook for user account activation in normal Wp (not MU)
- How to check if a stylesheet is already loaded?
- Mixing Regular Javascript With jQuery in a Plugin
- Plugin Upgrade Strategy
- Which are the hooks run before/after when a category’s deletion?
- get_the_excerpt() not working in plugin loop
- Where to call wp_enqueue_script in a plugin with custom template?
- How to prevent UNDO on guternberg block editor
- do_action and add_action on two different installed plugins won’t work
- How to override gutenberg paragraph block edit property
- How can I get the selected string when using a toolbar button in Gutenberg?
- woocommerce_checkout_order_processed hook executing function twice
- Authorizing a plugin to call Google Analytics v4 API on wp_cron
- WordPress pre_get_posts with combined results of two queries (OR)
- Plugin directory says that my plugin it’s not availabe in Spanish, but it is
- How to analyze wordpress plugin performance
- how to use shortinit in wordpress
- Using ob_get_content to get_search_form puts into infinite loop
- Alternatives to DISALLOW_FILE_EDIT wp-config Constant? It Breaks Some Plugins
- Declare plugin dependency [duplicate]
- Warning: call_user_func_array() expects parameter 1 to be a valid callback
- Jquery was not found on this server
- Is there an admin hook that will let me read GET variable before it’s too late to set the header Location
- WordPress plugin development OOP style
- Let plugin check if taxonomy is already registered by another plugin
- How to create a digital product download link that can’t be used twice?
- How to add custom post widgets as tags into wordpress
- Working of foreach loop with array
- Grandchildtheme (plugin) add header.php (not exist in child theme)
- Submit form to a different PHP file in the same plugin folder
- What might be the reason of Couldn’t fetch mysqli_result on another domain?
- How to get terms for taxonomy
- $wpdb->update Issue
- wp_insert_post generated mixed permalinks
- Adjust query on single
- Plugin won’t activate
- Is there any way to pass messages from a script to a redirect target in a hidden fashion?
- What should I pass for $needed_dirs when calling _unzip_file_pclzip (aka PclZip)?
- Custom Path for a Plugin
- Plugin could not be activated because it triggered a fatal error?
- How to make every image title equal to alt text(wordpress/woocommerce)?
- Load specific page when a custom URL is hit
- How to determine primary editor for a page/post
- Trigger function on Remove block or add new block in Gutenberg JavaScript
- WPGut – Updating failed and shortcode?
- Trying to rename a file upload as the hash of file content on wordpress
- Getting products information, in woocommerce based on products ID
- How the add_action is included in the plugin development
- Fatal error: Uncaught Error: Using $this when not in object context
- Error Connecting to Database WHEN Installing WordPress on XAMPP [Tried All the Usual Stuff] (Pics Included)
- How can I measure CPU and RAM used by my theme or plugin
- want to confirm popup with “Yes” and “No” button when user click on add to cart
- do I need to sanitize a shortcode’s function input?
- Email content as comment
- WordPress use template
- Warning: Illegal string offset – on homepage
- Modify search form with plugin
- Organising and completing posts (mark as read and hide)
- Query only title/field/featured media of posts [closed]
- To remove rendering of menus and header, plugin or theme?
- How can I give access to my plugin sections in admin?
- When using an options array the Settings API isn’t creating the database record
- Displaying External Data – Not Posts
- the correct way to use options from settings page [closed]
- On one of my sites a file is shown as 404 but the file IS there
- I want to add post meta for picture thum during submit for revision
- How to synchronize an e-commerce site and a pharmacy management software?
- woocommerce features to add product along with link
- Extend WP_List_Table class – Edit wp_usermeta – WPPB.me Boilerplate – Action error
- Find Any Theme’s page.php File
- WP Job Manager – Show recent jobs as cards
- Admin Menu for New Post
- multiple record insert creating many duplicate records