WordPress无限滚动插件选择器求助:如何获取正确选择器?
Hey there! Let's sort out those tricky selectors for your infinite scroll plugin—no more trial-and-error guesswork. Based on the code snippet you shared, here's how to lock in the right ones:
First, let's break down the three key selectors most infinite scroll plugins require:
- A selector for your post content blocks (the elements holding each individual blog post)
- A selector for the "Next Page" link (the link that triggers loading more posts)
- A selector for the pagination container (the full pagination section we'll hide once infinite scroll is active)
Recommended Selectors to Test
Let's map these directly to your site's structure:
Post Content Selector
Your posts are wrapped in<article>elements. Since your pagination uses the.mh-loop-paginationclass (common in MH Themes), your posts are likely inside a matching parent container. Try this first:.mh-loop-content articleIf you're unsure about the parent container, start simple with just:
articlePro tip: Use your browser's DevTools (F12) to right-click an article, then copy its full selector for pinpoint accuracy.
Next Page Link Selector
WordPress uses standard classes for pagination. Your next page link is almost certainly inside.nav-linkswith anextclass. Use this:.nav-links .next.page-numbersIf that doesn't work, target any link in the pagination section that isn't the "Previous" link:
.navigation.pagination .nav-links a:not(.prev)Pagination Container Selector
The entire pagination block is wrapped in.mh-loop-pagination—this is the element we want the plugin to hide once infinite scroll takes over. Use:.mh-loop-pagination
Quick Testing Tips
- Plug these selectors into your infinite scroll plugin's settings
- Load your blog page, scroll to the bottom, and check if new posts load automatically
- If it still fails, double-check the selectors in DevTools to ensure they only target the elements you need (no extra unrelated elements)
内容的提问来源于stack exchange,提问作者S R

