Building Prev / Next Posts with Query Loops in Bricks

Building Prev / Next Posts with Query Loops in Bricks

Following on from our tutorial on Adding Custom WP_Query Loops in Bricks, in this pro tutorial we'll walk through the process of using those same Bricks' filters to allow us to build custom adjacent posts ( or prev/next posts ) for use on a single post template.

We can then set up this query on the container element, meaning we can then build the layout how we like by placing elements inside and using any dynamic data from those posts. This gives us much more flexibility than using the native 'post navigation' element.

Adding the Adjacent Post Query

This code would need to be added outside of the builder, either inside your child theme’s functions.php file or a code snippet manager such as WPCodeBox.

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 525 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
Alternating Posts from Two Post Types in Bricks

Alternating Posts from Two Post Types in Bricks

How to output posts from two seperate post types, alternating in a query loop.
Categories:
Pro
Adding active class to the current term/post in a Bricks query loop on Term archives/single posts

Adding active class to the current term/post in a Bricks query loop on Term archives/single posts

Updated on 29 Feb 2024 In the Sibling Terms Bricks Query Loop tutorial, a member asked: How can I set the class "active" to the…
Categories:
Pro
ACF Post Object Query Loop inside a Posts Query Loop in Bricks

ACF Post Object Query Loop inside a Posts Query Loop in Bricks

How to loop through a CPT and within each post, output a list of related posts.
Categories:
How to add a layout toggle on query loops in Bricks

How to add a layout toggle on query loops in Bricks

In this tutorial, we’ll show you how to change the layout of your query loop container based on the click of an icon toggle sitting…
Categories:
Pro
Customizing ACF Repeater/Relationship or Meta Box Relationship Query Parameters in Bricks

Customizing ACF Repeater/Relationship or Meta Box Relationship Query Parameters in Bricks

For query types other than post, term and user in Bricks i.e, ACF Repeater/ACF Relationship/Meta Box Relationship there are no built-in controls for modifying the…
Categories:
Displaying SureCart Featured Products & Products Collections with a Query Loop

Displaying SureCart Featured Products & Products Collections with a Query Loop

We walk through how to use a query loop to display SureCart products, featured products & collections.
Categories: