Building With


Useful tips for building advanced blocks.

Query Loop – Related Posts

At the end of a single blog post, many sites show related content. With Query Loop, you can now dynamically pull in related articles based on categories.


Go to Appearance > Elements.



Click on Add New Element.

Elements Add New Element v2


Select Block for the Element Type and click on Create.

Element Type Block v1


You can name the Element anything you want. I named it “Related Posts”.

After naming the element, click on ‘+‘ sign to add a new block.

Related Posts Add Block v1


Scroll down to GenerateBlocks and click on the Query Loop block to add it.

Add Query Loop


Query Loop will give you multiple layout options. Select the one that best suits your blog.

Query Loop Layout Options


Leave the Select post type as Posts and you can modify the Posts per page to a number of your preference.

Query Loop Add Parameter


Select Taxonomies from the scroll-down menu.

Query Loop Taxonomies v1


Then select Categories for Taxonomies and select Current post terms for Select Terms.



Then select Categories for Taxonomies and select Current post terms for Select Terms.

Afterwards, click on Add Parameter because you will be adding a second parameter to exclude the current post.

Query Loop Current Post Terms v2


This time select Exclude posts from the drop-down menu.

The reason you would want to exclude the current posts is that you wouldn’t want the reader to see the current post they are already on as an option.

Query Loop Exclude Post v1


Scroll to the bottom of the page and you will see the Display Rules option. This allows you to select where you would like to see the related posts published.

Select Post and All Posts from the secondary menu.

Display Rules Post v1


On the far right-hand side, take a look near the top. You’ll find the option to switch from Block to Element. Click on Element.

Scroll down to Element Type and select Post Navigation.

Then go to Quick Hook Select and select After content container.

The Hook Name should be after_do_template_part.

Update the Priority to 1 and enable the Disable default post navigation by toggling the button.

Element Post Navigation v1

Final Results

Click on Publish, and you are done!

Now, if you go scroll down to any of your posts, near the bottom you’ll notice related posts show up.


Leave a comment