Sign in
We're evolving to serve you better! This current forum has transitioned to read-only mode. For new discussions, support, and engagement, we've moved to GitHub Discussions.

How to Limit the number of visible gallery images in the post

  • This topic has 1 reply, 2 voices, and was last updated 3 months, 3 weeks ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #10936
    Avatar photoAndy

    Hello,

    For a project, I need to add a dozen images to the gallery but I’d like to display 4 or 5 in the post and have the others only visible when the gallery is opened. Do you have any ideas on how to do this?

    Thank you in advance,

    #10944
    Avatar photoBob

    You can achieve this using CSS. While it might not be the most SEO-friendly solution, it is, in my opinion, the simplest and quickest one. If you want to display 4 or 5 items, simply adjust the number in the brackets to (-n+4) or (-n+5) accordingly.

    /* Initially hide all gallery items */
    .gallery__item {
      display: none;
    }
    
    /* Display only the first three gallery items */
    .gallery__item:nth-of-type(-n+3) {
      display: block;
    }

     

    --
    Do you appreciate the support you've received today? If so, consider donating to the Publii team by clicking here; we'll be sure to use your donation to make Publii even better!

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.