Custom looper - list all rooms except for current single page id

Hi there,

I’ve created a CPT called Suites and I am currently working on the layout of single-suite in layout builder.
Thing is, at the bottom of the page, I would like to create an other rooms section that changes dynamically based on which room we are one.

So as follows:

If we are viewing room 1, show room 2,3,4,5 at the bottom.
if we are viewing room 2, show 1,3,4,5 at the bottom.

Here’s a screenshot to show if not clear:

https://capture.dropbox.com/xuBU91lKcMWdaBrO

Anyhow, I’ve used query builder, and set it up so it displays all suites, the issue is, I can’t find a way to exclude the current room that we are on. So I get a faulty list.

Can you help me in achieving this?

Hi @Pbalazs89,

Thanks for reaching out.
You need to use the Query String instead of the Query Builder. I would suggest you go through the following thread on excluding the current post from the looper.



Hope it helps.
Thanks

Hi there,

So I managed the suites to get to show with query, unfortunately though, adding &post__not_in={{dc:post:id}} to the end of the query string causes it to throw errors. Here’s a brief video:

Hello @Pbalazs89,

In order to help you with your concerns we need to check your settings. I would request you, please share your details in a secure note. Please provide the following details.

  • WordPress Login URL
  • Admin-level username and password
  • Exact Layout URL

You can find the Secure Note button at the bottom of your posts

Thanks

Secure note added!

Hello @Pbalazs89,

I checked your setting I would suggest you please use this &post__not_in%5B0%5D={{dc:post:id}} instead of &post__not_in={{dc:post:id}} since post__not_in requires an array, please have a look at the WP Query.

So the updated Query String would be like this.

post_type=suites&offset=0&ignore_sticky_posts=1&post__not_in%5B0%5D={{dc:post:id}}

Hope it helps
Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.