24th Feb '23
/
0 comments

Custom Field Value based Adjacent Posts Navigation Query Type in Bricks

David Browne wrote Building Prev / Next Posts with Query Loops in Bricks tutorial in the past in which he showed how to add a custom "Adjacent Posts" option in the Query type dropdown for Bricks' query loops. The previous and next posts were based on the post's published date.

This Pro tutorial is a variation of the above for single posts where the previous and next posts are based on the value of a number-type custom field.

We are going to add a "Post Number" custom field using ACF (any other plugin like Meta Box /method can also be used), then assign numbers like 1, 2, 3, 4 (need not be sequential although it helps if they are). The objective is to show Post 2 as the previous post and Post 4 as the next post when viewing Post 3 for example.

Add the following in child theme's functions.php (w/o the opening PHP tag) or a code snippets plugin:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 610 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

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:
How to create filters with IsotopeJS in Bricks (Part 1)

How to create filters with IsotopeJS in Bricks (Part 1)

This tutorial series will explore the IsotopeJS library's features inside the Bricks ecosystem.
Categories:
How to hide/remove the Block Element from the Bricks Builder

How to hide/remove the Block Element from the Bricks Builder

Don't like the new Block element in Bricks? Just copy/paste the following code into your child theme's functions.php. By the way, It's a terrible idea…
Categories:
Tags: