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):
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.
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!
- post_type –> [ oxygen data=’post_type’ ]
- tax_query –> array:
- taxonomy –> category
- terms –> add value –> [ oxygen data=”post_terms” taxonomy=”category” ]
- field –> slug
- no_found_rows –> true
- posts_per_page –> 6 (you can change this number to the maximum number of items you want to display)
- 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.