Halloween Sale 15% off Ends in See the plans
HTML

"Continue Where You Left Off" on Long Articles

Remembers how far a reader got in a long post (in their own browser only) and offers a "Continue reading" button when they come back, without cookies or accounts.

Don’t have WPIDE yet? Install it on your site

Code

<div class="wpide-resume" hidden role="status"><span>Continue where you left off?</span> <button type="button" class="wpide-resume-go">Continue reading</button> <button type="button" class="wpide-resume-close" aria-label="Dismiss">×</button></div>
<style>
.wpide-resume{position:fixed;left:50%;bottom:20px;transform:translateX(-50%);z-index:9990;display:flex;align-items:center;gap:10px;max-width:calc(100vw - 32px);padding:10px 14px;border-radius:10px;background:#1d2327;color:#fff;font-size:14px;box-shadow:0 8px 24px rgba(0,0,0,.25);}
.wpide-resume[hidden]{display:none;}
.wpide-resume button{border:0;border-radius:6px;background:#fff;color:#1d2327;font:inherit;font-weight:600;padding:6px 10px;cursor:pointer;}
.wpide-resume .wpide-resume-close{background:transparent;color:#fff;font-size:20px;line-height:1;padding:2px 6px;}
</style>
<script>
(function () {
    if (!document.body.classList.contains('single-post') || document.documentElement.scrollHeight < window.innerHeight * 3) { return; }
    var key = 'wpide-read-' + window.location.pathname, store;
    try { store = window.localStorage; store.getItem(key); } catch (e) { return; }
    var box = document.querySelector('.wpide-resume');
    var saved = parseInt(store.getItem(key) || '0', 10);
    if (box && saved > window.innerHeight * 1.5) {
        box.hidden = false;
        box.querySelector('.wpide-resume-go').addEventListener('click', function () { window.scrollTo(0, saved); box.hidden = true; });
        box.querySelector('.wpide-resume-close').addEventListener('click', function () { box.hidden = true; });
        setTimeout(function () { box.hidden = true; }, 12000);
    }
    var timer = null;
    window.addEventListener('scroll', function () {
        clearTimeout(timer);
        timer = setTimeout(function () {
            var y = window.pageYOffset;
            var nearEnd = y + window.innerHeight > document.documentElement.scrollHeight - 400;
            try { if (nearEnd) { store.removeItem(key); } else { store.setItem(key, String(Math.round(y))); } } catch (e) {}
        }, 400);
    }, { passive: true });
})();
</script>

Notes

Uses the browser's localStorage, which is not sent to your server. Only single posts longer than about three screens are tracked.

How to add this snippet

  1. Install WPIDE on your WordPress site (it is free) and open Code Snippets.
  2. Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
  3. It is added inactive: review the code and settings, then switch it on.

Have a snippet worth sharing?

Publish it to the library from WPIDE or right here. Sign in with any WordPress site that runs WPIDE, free or Pro. Public snippets are reviewed by the WPIDE team before they appear.

Which site should get this snippet?

Enter the address of your WordPress site. WPIDE opens there in a new tab with the snippet ready to review and save.

Remembered in this browser only, so you are asked once.

Report this snippet

Tell the WPIDE team what is wrong: broken code, something harmful, spam or copied work.