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 626 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

How to Remove Name and Website Fields in Bricks Comment Forms

How to Remove Name and Website Fields in Bricks Comment Forms

Updated on 14 Mar 2024 In the BricksLabs Facebook group a user asked: What is the best method to remove fields from the Bricks "Comments"…
How to create filters with IsotopeJS in Bricks (Part 4): AJAX filter and infinite loops, Sorting, List view and Disable animations

How to create filters with IsotopeJS in Bricks (Part 4): AJAX filter and infinite loops, Sorting, List view and Disable animations

This tutorial will explain how to enable the AJAX filter with an infinite scroll query loop container, how to add a sorting function, how to…
Categories:
Pro
Conditionally Hiding Bricks Filters based on Select Filter Value

Conditionally Hiding Bricks Filters based on Select Filter Value

How show or hide Bricks' filter based on the selection made by another filter.
Categories:
Tags: