Recently Viewed Posts Bricks Query Loop

Updated on 6 Mar 2024

This Pro tutorial provides the steps to output the most recent x number of posts (can be of any specified post type) viewed by the current visitor (need not be logged-in) in a Bricks query loop.

We shall use cookies to track the posts viewed. If you have a GDPR cookie notice in place and the user has yet to agree to store the cookies on their computer, this solution won't work. In such a case, there will be simply no output.

Update 1: Added instructions for showing the recently viewed products.

Step 1

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

Instant access to 390+ Bricks code tutorials with BricksLabs Pro