How To Add Related Posts Between Paragraph Content

This code enables you to pull related posts from your database and display them in a grid within the content of your post or page using a shortcode or Gutenberg / Genesis block.

The solution uses CSS display:grid; to print each entry in a 3 column grid.

Demo Video

Shows the related shortcode added between paragraphs of content on the Edit post screen display related posts.

Tested using the Genesis Sample child theme by StudioPress however will work in any Genesis child theme or any WordPress theme if you swap out the genesis_get_image function with the_post_thumbnail

Installation Steps

There’s 2 steps :

  1. # Copy & paste the PHP code ( without the opening PHP tag ) from the functions.php file to the end of your child themes functions file.
  2.  

  3. # Copy & paste the CSS to the end of your child themes style sheet and clear caching.
  4.  

You can then add the [related] posts shortcode within the content of your post or page like this :

Download Folder

Related Code

Was This Tutorial Helpful?

Free

$0

Access only to all free tutorials per month.



Monthly

$75

Access to 10 premium tutorials per month.


Tutorial Request


Includes code guarantee and coding support.

Yearly

$500

Access to 15 premium tutorials per month.


Monthly Tutorial Request


Includes code guarantee and priority coding support.