Site wide Query Loop on Archive Pages

Hi there,
Sorry if this is a newbie question. I’ve use the Related Posts template to return 5 x recent posts on my sidebar (using Query loop).

When I view an Archive page, it seems to be applying a filter of category=whatever archive page i’m visiting.

How do I get query loop to drop that condition so it just displays (for example) 5 most recent posts irrespective of the Archive page i’m currently viewing?
This only seems to be happening on Archive pages and is fine on individual pages and posts.

Many thanks in advance

Hi Valiant,
Welcome to the forum!

This sound like a perfect use case for the merge_query filter.
Please take a look at the Bricks academy.

Best regards,
timmse

Thanks Timmse! Apologies, I’m not really a developer, so is this essentially using a child theme and adding this code snippet into the functions.php to edit the query (and set it to false for the related posts?)

Thanks

Yes.

Copy that entire code and paste it in your child theme’s functions.php.

Then change wghgco to the correct element ID.

Thanks Sridhar! Will give this a try :slight_smile:

So there is currently no ‘current loop’ or ‘current posts’ options like we used to have in Oxygen?

For most (if not all) archive pages and the like this seems a default need, you want them to behave like normal and grab the posts for that archive right? So not sure why custom code is required to achieve it :confused: