如何停止WordPress或插件在商品页面的自动滚动?
Hey there! Let's tackle that annoying auto-scroll issue on your WordPress product page. I’ve broken down actionable fixes to help you disable this behavior:
Auto-scroll typically stems from a plugin (like a product gallery or custom script) or your theme’s built-in functionality. Here’s how to fix it:
1. Rule Out Plugin Conflicts
- Disable your plugins one by one, reloading the product page after each disablement. When the auto-scroll stops, you’ve found the problematic plugin.
- If it’s a product gallery plugin, check its settings for "auto-scroll," "carousel auto-advance," or similar options—toggle those off first before disabling the whole plugin.
2. Block Scroll Behavior with Custom CSS
If smooth scroll settings are causing unintended auto-scroll, add this code to your theme’s custom CSS (go to Appearance > Customize > Additional CSS):
html, body { scroll-behavior: auto !important; }
This overrides any forced smooth scroll that might be triggering the auto-scroll effect.
3. Disable Script-Triggered Scroll with JavaScript
If the issue comes from a custom script, add this snippet to your theme’s footer (via a custom HTML widget or child theme’s footer.php file):
document.addEventListener('DOMContentLoaded', function() { // Block untrusted script-triggered scroll events window.addEventListener('scroll', function(e) { if (!e.isTrusted) { e.preventDefault(); } }, true); });
Note: This blocks scrolls initiated by scripts (not user-triggered ones). If it breaks a feature you need, use your browser’s DevTools (F12) to search for keywords like scrollTo or scrollIntoView in the Sources tab to pinpoint the exact script causing the issue.
4. Check Your Theme’s Settings
Some WordPress themes include built-in scroll effects for product pages. Head to Appearance > Customize and look for options like "Product Gallery Auto-Scroll" or "Smooth Scroll"—toggle those off if they exist.
内容的提问来源于stack exchange,提问作者SHON WILLIAMS

