Published on April 15, 2021

Accessing the Default Query in Oxygen’s Code Block

Sridhar Katakam

Oxygen's Easy Posts and Repeater components can be used on listing pages like archives and blog posts index for outputting a bunch of posts whose information is available in the main query. It is important to leave the query type to Default to the extent possible.

There are certain situations when you need to have full control of the query's loop including setting what the parent container of the posts should be (like when you want the posts to be output as an ordered/unordered list). For this we could use a Code Block and typically the way we do it is to set up our query's $args and create a new WP_Query( $args ) and access this $query in the subsequent loop.

But what about the case where the main query already has the info about all the matching posts like on archives or the Posts page (blog posts index)? This members-only tutorial shows a sample code for accessing the default query and using it for the loop output.

In an Oxygen Template that applies to an archive (could be one that applies to all achives or to all categories etc.) add a Section and inside that a Code Block.

PHP & HTML:

This is a premium members-only content.

To view the rest of the content, please sign up for membership ($47/month or $499 one-time).

Already a member? Log in below or here.

tagschevron-leftchevron-rightchainangle-rightangle-upangle-downfolder-omagnifiercrossmenuchevron-downarrow-right