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

Instant access to all 250+ Bricks code tutorials with BricksLabs Pro