This will allow you to limit how many times the load more button can be clicked to show more posts.
Change if (clickCount > 1) { to however many clicks you want.
Change window.location.href = 'https://voxel.guide/login-registration/'; to your login URL.
<script>
document.addEventListener('DOMContentLoaded', function () {
// Check if the user is logged in
// This checks for a specific class on the body tag which is common in WordPress
const userLoggedIn = document.body.classList.contains('logged-in');if (!userLoggedIn) {
const loadMoreButton = document.querySelector('.ts-load-more');
const storageKey = 'loadMoreClickCount';
let clickCount = parseInt(localStorage.getItem(storageKey)) || 0;loadMoreButton.addEventListener('click', function () {
clickCount++;
localStorage.setItem(storageKey, clickCount);if (clickCount > 1) {
window.location.href = 'https://voxel.guide/login-registration/';
}
});
}
});
</script>