Query same category posts in Oxygen repeater and exclude current post

2 min readAug 3, 2022

Here is a tutorial on how to create a “related posts” repeater where categories of the post you are currently viewing will be queried whilst excluding the current post itself for better user experience.

My past iterations of this website used to have a sidebar which would always show the most recent 6 posts of the same category as the current post but excluding the current post. This is a fantastic way to allow users to explore more posts without having to go to a post archive page or simply exit the website. In fact, after doing this, my GA bounce rate saw some serious improvements!

I’m sure there is an easy way to do this but here is how I achieved this (please note, I will skip the styling portion):

The steps

Query dynamic data

Drop in an Oxygen repeater element wherever you want to show the post list and then drop in elements to query the relevant dynamic data as you require.

For example, I will simply drop in a heading (h4) element > double click on the default text > select Dynamic Data > select Post Title > check the Link option.

Doing the above steps will allow us to quickly see if the repeater query is working correctly.

You can of course style all these elements at any time as per your design requirements.

Query repeater

Go to the repeater panel > select Query > under Advanced > select Edit Query > then clear any queries that may be there by default by clicking on the bin icon and add the following queries:

Note: Please remove the space between the square brackets below!

  1. post_type[ oxygen data=’post_type’ ]
  2. tax_queryarray:
  • taxonomycategory
  • termsadd value[ oxygen data=”post_terms” taxonomy=”category” ]
  • fieldslug
  1. no_found_rowstrue
  2. posts_per_page6 (you can change this number to the maximum number of items you want to display)
  3. post__not_in [ oxygen data=”id” ]

Once you have added the above queries, you can close the query pane and then click save on the top right of the Oxygen editor.

Provided you correctly added the above queries, you should now see the correct type and number of posts in the front-end.

For more WordPress tips, tricks, and tutorials visit my site.


I am currently a financial analyst training to become a chartered accountant. In my spare time, I build and blog about WordPress and VBA solutions for people.