You need to limit yourself to the main loop and this can be done by checking if is_main_query returns true.
This might not be enough as that hook/filter was probably designed with the intention of augmenting the summery and therefor might be called more then once even during execution of the main loop itself. You have two option here
-
Use a much better hook. The hook name doesn’t sound like something you should trigger any DB write on.
-
call
remove_filter
to remove it after the first iteration was done.
Related Posts:
- WooCommerce: change display order of product short description and price [closed]
- How to remove action hook done in a plugin from functions.php in my theme?
- WooCommerce New customer email Hook? [closed]
- Add my own function to existing WooCommerce hook
- WooCommerce – Overwrite action hook [closed]
- Can I remove WooCommerce main content hook?
- Using hooks with extra parameters
- WooCommerce single product page quantity description [closed]
- Execute JavaScript in WordPress Hook
- Woocommerce table is missing a heading–can I add it by use of a hook?
- Change user role if it’s orders count more than
- Hook that fires when admin setting is saved
- Is there a WordPress core & plugins update action hook?
- trigger save_post event programmatically
- is it possible to get the hook name in add_action?
- What hook is executed just after wp_query has been executed?
- WooCommerce: How to display item meta data in email confirmation using woocommerce_order_item_meta_end
- How to properly test a method that is called by an action hook
- How can I do customizations on login, registration and password recovery forms?
- How to Remove a Filter from the Admin List Table?
- Custom form action hook
- Woocommerce, recognize the loop of related products
- display available size on hover, in woocommerce shop page [closed]
- How to send an automated user ‘inactivity’ email?
- How do I successfully create a hook for an email override?
- Cast string to number
- How to debug user_register hook
- How to add a second ‘place order’ button in WooCommerce [closed]
- Storing state between hook functions
- What’s the difference between “wp” and “wp_loaded”?
- WordPress capabilities and restricted categories access
- How to use custom form on add_meta_boxes callback
- Is it possible to switch Gutenberg’s editor styles when document settings change?
- Add a product to checkout via form
- schedule event in class oriented plugin
- How can I find the hook I need to rewrite a function?
- Show message in media-new.php
- Hooks are not being removed in child theme
- How to Update the Order-Items While Editing an Order on the WooCommerce Admin Order Screen [closed]
- add_action second argument missing
- How to get user meta fields that have just been updated?
- admin_notices action doesn’t trigger within save_post action
- When a plugin gets updated from the repo, does the “activation” hook fire again?
- Defining hooks within (php)classes?
- WooCommerce change Tax Class programmatically when Recalculating an existing Order [closed]
- Divi hook not working [closed]
- Add WordPress hook outside of Plugin or Theme
- How to perform action when plugin/theme editor is used?
- Filter default_content only for products
- How to run hooks one by one manually?
- How can I override wp_price woocommerce function in my theme
- Hide one specific woocoomerce product
- What is the proper hook to use for recording a post view?
- How to load this code on function.php
- Woocommerce single_product_summary hook not working
- Where is publish_post hook fired?
- A good hook to check authorization and redirect?
- Bloginfo hook – can it be more precise?
- Custom posts and get_post_meta in {$post_status}_{$post_type}
- Hooking custom PHP output into WP: how to do it, parse_request almost works but not quite
- Print on screen during shutdown hook – error during saving in theme-editor.php
- Conditionally run function based on custom meta value?
- How to stop execution of a function via add_action hook?
- changing genesis_before_while in new theme framework
- Moving Javascript from footer to header
- Adding a new hidden field based on a condition in Ninja Forms
- Display custom field value in woocommerce variable product via jQurey
- Forcing WooCommerce customers to create account before checking out
- Store user ID on wp_term_taxonomy when new term inserted
- ‘user_register’ hook – need to distinguish if created from wp admin panel
- Make multiple URLs behave as home page
- Parameters in woocommerce_before_add_to_cart_button hook
- Discount in the specific product title using keyword ( Woocoommerce )
- Transition_Post_Status hook not working properly
- Wodpress XML Import hooks
- profile_update hook does not fire from front-end
- wp_update_post not getting triggered by hook
- How to get user profile information before update?
- Why is pre_get_posts hook invoked multiple times?
- Undefined fieldId in gform.addFilter for limiting dates in datepicker – Gravity Forms
- wordpress plugin translation not working
- Woocommerce: Unique price for individual basket items
- Get First Post content and edit it using pre_get_posts (or similar?!)
- Are there Hooks for featured image popup?
- Clone the “proceed to cart” button and place it above checkout on the cart page, but only appear display size is 320px
- WordPress sending data with add_action
- How to hide / remove attachment “alt” or “caption” field in Admin?
- Why does get_post() not return anything?
- Hourly events don’t get triggered
- Using actions, hooks and filters in a non-WordPress page
- Hook into create_category
- Trouble adding data to options table
- How to hook into publish_posttype?
- $GLOBALS & global doesn’t work [closed]
- Hooks not working on live server
- Add second price option based on payment method at cart item price
- WP: Override/update the_content from database with the publicly echo the_content
- What is the equivalent hook for both admin_head() and wp_head() combined, if any?
- Search WordPress Hook for completed Elementor Update
- How to filter the URL of thumbnail size in the Media Grid and admin pages