Displaying Related Post Content on a Category Archive Page in Bricks

In this Pro tutorial for Bricks users, we shall

  • use Crocoblock JetEngine (any other custom fields plugin can also be used) to select one Post for category archives
  • display the WordPress editor content with all formatting intact and featured image for the selected Post on the corresponding category archive pages

Use case: This method is useful when you want to associate or link a particular post to each of your categories. Once done, when any category archive page is viewed we can show the title, the full WP content and the post's featured image that is connected to the current category in a Section. For example, you could set up the archive template to show the h1 term title at the top, then the related post's Section which could act as the category's intro and then another Section that shows all the posts in that category.

Step 1

Install and activate JetEngine.

Go to JetEngine → Meta Boxes.

Add a new meta box of the type "Posts" for Categories taxonomy.

Note that the Name/ID of the field is category-to-post. We will be using this in a later step.

Step 2

Edit your categories and select a post for each.

populating-category-to-post-custom-field-category

Step 3

Edit the template that applies to categories with Bricks.

Add a Code element where you would like to output the linked post's content having this code:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 526 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
Term Specific Colors in Bricks

Term Specific Colors in Bricks

This Pro tutorial provides the steps to add a class or a data-<taxonomy> attribute to terms of the current post for the given taxonomy so…
Adding any Custom WP_Query loop to Bricks’ Query Loop

Adding any Custom WP_Query loop to Bricks’ Query Loop

Sometimes we may need to create a custom post loop using Bricks' query loop feature, but wish to use our own WP_Query code for more…
Conditionally Outputting Based on Query Count in Bricks

Conditionally Outputting Based on Query Count in Bricks

Update on 22 Sep 2023: There's a much simpler built-in method now. See this post. In the Bricks Facebook group a user asks: Is there…
Categories: