I believe changing the following conditional:
if( !current_user_can( 'manage_options' ) )
to this one:
if( !current_user_can( 'manage_options' ) && 'product' === $query->get( 'post_type' ) )
would do it.
Brief explanation: I added a second condition which checks if the query is for WooCommerce products where the post type is product.
UPDATE
If you want to make certain that the code runs only on the products page (WooCommerce → Products), then you can (remove the global $pagenow; and) change this:
if( 'edit.php' != $pagenow || !$query->is_admin )
to this one:
if( !$query->is_admin || 'edit-product' !== get_current_screen()->id )
And instead of relying on the global $user_ID, you should probably use get_current_user_id(): $query->set( 'author', get_current_user_id() ); 🙂
Related Posts:
- WooCommerce Checkout Issue specific to Instagram In-App Browser
- Checkbox field that add a subscription product and change prices of other products in checkout and cart page
- Use Case: Multiple Shipping Methods per Order
- How to access custom post meta data from JavaScript
- Woocommerce functions in custom class, avoid errors
- Co-author plus: list of posts by authors in the sidebar
- Display Woocommerce attribute name above product title
- In woocommerce, is there any way to empty wordpress default mini cart when order placed?
- In woocommerce, is it possible to make payment of one customer order by another customer?
- Get a list of Product Categories inside a loop
- woocommerce with external ftp site
- Woocommerce – Change variations output
- Meta Key array building with multiple input values from fields
- Object of class WP_Error could not be converted to string in /formatting.php
- Woocommerce budget search
- Only return taxonomies that are linked to a category & product
- Changing author slug for a custom role without using plugin
- WordPress eMails not working
- WooCommerce or any other plugin: Deliver JS and CSS through CDN without using a Plugin
- Add WooCommerce vendor slug to auto-generated SKU
- Remove dashboard links from wordpress
- Tracking sales/conversions in Woocommerce using Google Analytics
- How Can I display Specific User Pages?
- Plugin for showing single product on a page
- Coupon Codes for product discount combined with conditional free shipping
- Custom product page’s style for printing
- wc_get_product_terms() throws “Notice: Undefined offset: 0”
- Configuring default woo commerce login with modal popup
- Custom plugin issue – Notice: Trying to get property of non-object in
- fetch price from different table woocommerce
- Woocommerce list variations that are added already to cart in Single Product
- Cannot save a custom meta field in quick edit
- {status}_{post_type} does not run correctly?
- How to capture customer’s credit card details via PayPal on my checkout page?
- Not displaying Woocommerce product page in lightbox
- Saving data only when payment is successful
- Fetching users data from REST API
- Automatically check “Enable stock management at product level” to the existing products?
- Change (replace) word in metabox
- how to make settings page for woocommerce plugin?
- How to get the total count of Favorite/Favorited authors
- Change hook to add_action in a plugin class
- redirect to a custom page
- wordpress plugin translation not working
- Woocommerce categories displayed on every category and shopping page
- Allow vendors on a WordPress site to pick from a gallery of pre-selected images when choosing product’s featured image
- Hide ‘add to cart’ button for some products [duplicate]
- 504 Timeout gateway when trying to pay for an order in Woocommerce. What else can I do?
- Change pricing in Woocommerce based on Category and Product [closed]
- woocommerce product search based only title
- Template conflict with WC Payment Method
- Many to many relationship for variable products
- Need woocommerce function for getting cart list with items
- WPNeo Stripe connect does not work
- Payment failed but order is placed on wp site
- How to change the product short description for each product with PHP?
- Adding/ Removing actions for plugins
- Get value from an input field and pass into update_meta_data as $meta_value
- Help needed with woocommerce (wc stripe) filter
- Widget logic using woocommerce product category
- how to show Author group not Author name
- Change value of Points earned in product data
- Problem with conditional woocommerce custom checkout field
- Unable to sync woocommerce variations
- How to prevent authors from editing their post count?
- WordPress Theme Conflict With Plugin
- How to Save settings of custom tab product page in admin side in a database?
- change product image url in widgets & shop page
- How woo-commerce store Product Data value in DB?
- Displaying friend’s posts only
- Not getting result using ajax on wordpress
- How to allow customers to input a text as a product variation *and* charge per character?
- woocommerce blank page after clicking add to cart [closed]
- Which WordPress version to use for improved plugin compatibility? [closed]
- Run one-time script calling plugin functions
- Woocommerce: deleted single-product.php, everything still works. How is it possible?
- Holding 2 wp_user in the same action (to update billing_email when user_email is updated)
- How to show author’s avatar in the post meta data with plugin `user-avatar`
- Unfortunately removed myself as plugin committer
- Check if post was modified by editor different than post author
- Woocommerce Bookings – Resource needs to be allocated for part of the booking duration, not the whole booking
- Want to add post to user dashboard
- Unable to show 4 products in a row
- Sort Reviews/Ratings by date on Woocommerce
- Move related products after product summary? [closed]
- Add A Button to WooCommerce Product Page
- WooCommerce doesn’t show UK countries in the shipping options [closed]
- Woocommerce quick checkout form [closed]
- Woocommerce Large Variations Shows Out of Stock Items [closed]
- Turning Existing Eccommerce Site into Multi-SIte
- How ACF Advanced Custom Field works with Woocommerce Single Product [closed]
- is_plugin_active() not defined on active plugin, in the thumbnails.php file
- The plugin generated xxx characters of unexpected output during activation
- WooCommerce custom query and paging: Not Found error
- WooCommerce & WooCommerce Shopee Intergration
- How to execute init or woocommerce_init only for checkout page
- WP Customer Reviews call short code on another page [closed]
- Trying to disable all notifications except for one on woocommerce checkout page with css [closed]
- Woocommerce – Product Description heading [closed]
- Need help saving input fields for Security Deposit plugin in WC Vendors page