Skip to main content
All CollectionsWidgets and Advanced How-to's
How to limit or restrict the number of cards shown in a gallery collection
How to limit or restrict the number of cards shown in a gallery collection

This is a really good tip for showing only recent posts.

Cam Incoll avatar
Written by Cam Incoll
Updated over a year ago

Sometimes you'd like to be able to restrict the number of items shown in the gallery collection. For example just say you want to show the six most recent blog posts from your blog database.

Here is some custom CSS to be able to do this, Add this CSS to the Code > CSS section:

.notion-collection-card:nth-child(n+7) {
display: none !important;
}

This will hide the 7th and subsequent gallery cards. Adjust the value 7 to show more or fewer cards.

Note that this will affect all gallery collections.

How to target a specific gallery

If you want to target a specific gallery then you'll need to get the block ID of the gallery by inspecting the page code.

Use the browser developer tools to inspect the code and select the gallery.

Here in this example the notion-collection has a block ID of
โ€‹block-f8867ff194484e08a0ff2e87cf889e62

Add the block ID to the CSS:

#block-f8867ff194484e08a0ff2e87cf889e62 .notion-collection-card:nth-child(n+7) {
display: none !important;
]
Did this answer your question?