header-logo
Getting started with WixBuild your website and business with Wix. Try using our AI tools to create your website, customize templates, or hire professionals to build or enhance your online presence.
Creating a websiteRead how to use the Wix Editor and manage content on your site. Discover how to protect your visitors' privacy and make your site accessible.
Account & billingReview your account settings, manage your subscriptions and plans and understand your invoices.
Using the Wix mobile appsUse our mobile apps to run your business efficiently on the go and set up a dedicated app for your site members to stay in touch.
Connecting a domainFollow our step-by step guides to learn how to purchase, connect or transfer a domain for your site, and find out how to keep your site’s data secure.
Managing your businessGet tools to grow your business and web presence. Find the right tools for your specific needs, set up online payments and keep track of your site's analytics.
Promoting your siteLearn to make your site more visible promoting it on search engines, sending emails and running paid ads. Improve your online presence with practical tips.
Studio, Partners & EnterpriseGet the most out of your Studio or Enterprise account with advanced features that'll help you work more efficiently.
Need more help?Find solutions for site performance and technical issues, learn about issues we’re working to fix or contact us for help.
placeholder-preview-image
Wix LearnImprove your skills with our courses and tutorials.
Wix BlogGet tips for web design, marketing and more.
SEO Learning HubLearn to increase organic site traffic from search engines.
Website developmentBuild a custom site using our full-stack platform.
Hire a ProfessionalGet matched with a specialist to help you reach your goals.
placeholder-preview-image

CMS Request: Looping Previous/Next Navigation Buttons on Dynamic Item Pages

Feature Request|We are collecting votes for this issue
Currently, 'Previous/Next' navigational buttons on dynamic item pages do not loop. When a visitor gets to the last item page returned by the dataset, the 'Next' button is inactive. Similarly, when a visitor is on the first item page, the 'Previous' button is inactive. It is not possible, without using Velo code, to have these buttons continue to navigate visitors through all the items. 
We are always working to update and improve our products, and your feedback is hugely appreciated.

Workaround

Using Velo, you can create 'Previous/Next' buttons that loop to continuously navigate through your dynamic pages. 
  1. Go to your editor.
  2. Go to the dynamic item page that has 'Previous/Next' buttons. 
  3. Make sure your 'Previous/Next' buttons' click actions are not connected to the dataset:
    1. Click your 'Previous' button and click the Connect to CMS icon.
    2. Click the Click action connects to drop-down and select Not connected
    3. Repeat steps 3a-3b with your 'Next' button. 
  4. Enable Velo Dev Mode: 
    1. Click Dev Mode at the top of the editor. 
    2. Click Turn on Dev Mode
  5. Copy the code snippet below and paste it at the top of your page code:
1import wixLocationFrontend from 'wix-location-frontend';
  1. Copy the code snippet below and paste it after: $w.onReady(function () { 
1$w('#prevBtn').onClick(async () => {
2       const previousPage = await $w('#dynamicDataset').getPreviousDynamicPage();
3       if (previousPage) { wixLocationFrontend.to(previousPage) }
4       else { wixLocationFrontend.to('/last-page-url') }
5   })
6   $w('#nextBtn').onClick(async () => {
7       const nextPage = await $w('#dynamicDataset').getNextDynamicPage();
8       if (nextPage) { wixLocationFrontend.to(nextPage) }
9       else { wixLocationFrontend.to('/first-page-url') }
10   })
  1. In the sample code you pasted, replace the IDs and URLs listed below with those used by your site: 
    • prevBtn Replace with the ID of your 'Previous' button.
    • nextBtn Replace with the ID of your 'Next' button.
    • dynamic Dataset Replace with the ID of your dynamic page dataset.
    • /last-page-url Replace with the URL slug of the last dynamic item page read by the dataset. 
    • /first-page-url Replace with the URL slug of the first dynamic item page read by the dataset. 
Tips:
  • Click the relevant button or dataset to find its ID in the Properties and Events panel. Do not remove the hashtags (#) or apostrophes (') in the code.
  • To get the correct first and last dynamic item page URLs, create a custom collection view with the same sorting and filtering as in the dataset settings. You can copy the URL slug from the [Collection] (Item) page link field in your collection.