Post looper to not display current post

Good afternoon, within blog posts I have created a layout which displays two other blog posts at random at the bottom that the user may be interested in - funny enough I have called this section ‘You may also be interested in’

I have this via the posts ‘loop’:

How can I have it so it does show the current post it is within. So for example if I am on the post ‘A Few Observations on the Medieval Moated Manor House’ it does not show that in the loop:

Thank you!
Jason

Hello @hyperdrive_boom,

Thanks for writing to us.

I checked your settings, and it seems that you have set the post order as random, which is randomly displaying the posts.

In case you want to display the related post, including current posts. I would suggest you please set the Looper provider as a query string and add this query string.

 category__in={{dc:term:id}}&post_type=post&posts_per_page=2 

Thanks

Good evening and thank you for this,

I would like it so it shows any posts apart from the current post it the user is reading. What would the updated query string be for this?

Thank you!
Jason

Hi Jason,

You need to exclude the current post id in the Query String by adding the post__not_in. You can get more details on the post__not_in in the following thread.

Hope it helps.
Thanks

Good morning and thank you very much for the reply - based on what you sent I put this together:

post_type=post&posts_per_page=2&post__not_in%5B0%5D={{dc:post:id}}

At first it only seemed to work when a user was logged in but it seems to be find now for everyone

Thank you!
Jason

Hello Jason,

Glad that we were able to help you and you were able to edit the query as per your requirements and achieve the solution.

Thanks