Skip to main content

Related Box Shortcode

[ruby_related] draws a box of related posts inside a post's content: a heading, then a few posts that share a category or a tag with the post being read.

A More Read related box inside a post on the Foxiz Default demo: the first related post with a thumbnail and the rest listed as links

You use it in two places:

The shortcode to start with​

Copy this one. It shows four related posts in a full width box under the heading More Read:

[ruby_related heading="More Read" total="4" layout="1" where="all" order="rand" style="default" width="wide"]

It is the example the theme itself puts in the Theme Options field, with total lowered from 5 to 4.

Always write total. Left out, the box shows only 2 posts.

More shortcodes to copy are in Ready-made shortcodes, and what each part means is in Every parameter.

Add the box to every post​

Foxiz can insert the box into every post after a set number of paragraphs. This is the Inner Content Related feature, and it runs on the shortcode you paste into Theme Options.

  1. Go to Theme Options > Single Post > Related & Popular.
  2. Scroll to the Inner Content Related group.
  3. Paste your shortcode into Related Shortcode. The field is empty on a new site, and while it is empty no box appears in any post.
  4. In Display Positions, type after how many paragraphs the box goes. The default is 5. Separate several positions with commas, such as 5, 8, to show the box more than once.
  5. Click Save Changes.

The Inner Content Related group in Theme Options > Single Post > Related & Popular: Related Shortcode holds the ruby_related shortcode with heading More Read, total 4, layout 1, where all, order rand, style default and width wide, outlined in orange, and Display Positions holds 5

Open a long post to check. A post with fewer paragraphs than the position gets no box.

The other reasons a box does not show, and the related section at the end of the post (a separate setting in the same panel), are in Automatically Adding Related Posts via Theme Options.

Change or turn off the box on one post​

Each post can override the Theme Options setting:

  1. Open the post: Posts > All Posts, then Edit under its title.

  2. Scroll below the content to the Single Post Settings box and open its Inline Related tab.

    The block editor on a page with the settings sidebar closed: the page title and content, and at the foot of the screen the collapsed Meta Boxes bar, outlined in orange.

  3. Set it up:

    • Inline Related Posts: Disable removes the box from this post. - Default - keeps it.
    • Display Positions: positions for this post only, such as 3 for a short post. Leave it empty to use the Theme Options positions.
  4. Click Update.

The Inline Related tab of the Single Post Settings box on a post's edit screen, with Inline Related Posts on - Default - and 3 in Display Positions, both outlined in orange

Add the box to one post​

For one box at an exact spot, for example in the middle of a long guide:

  1. Open the post: Posts > All Posts, then Edit under its title.
  2. Click where the box should go and add a block with the + button.
  3. Choose one of these:
    • Related Posts - Ruby, the easier way for most sites. Search Related and add it. It writes the shortcode for you from dropdowns and shows a preview. See How to Use the Related Posts Block.
    • Shortcode, to type the shortcode yourself. Search Shortcode, add the block and paste a shortcode into it.
  4. Click Update.

Searching related in the block inserter returns the Related Posts - Ruby block

A Shortcode block in the post editor holding [ruby_related heading="More Read" total="4" layout="1" where="all" order="rand" style="default" width="wide"].

The shortcode also works in the Classic Editor and in Elementor's Shortcode widget.

A post that holds its own related box skips the automatic one, so a reader never sees two. You can leave the automatic box on for every post and still place it by hand where one post needs it somewhere else.

Ready-made shortcodes​

Copy one, paste it into Related Shortcode or into a post, and change the heading to your own words.

A small box beside the text. Three posts with thumbnails, in a column on the right that the text wraps around:

[ruby_related heading="Read Also" total="3" layout="2" width="right"]

A list of titles only. No images, five posts:

[ruby_related heading="Related Stories" total="5" layout="4" width="wide"]

A grid of image cards. Three cards in a row, one per row on phones:

[ruby_related heading="You May Also Like" total="3" layout="6" width="wide"]

One large image, then titles. The first post as a card with a big image:

[ruby_related heading="More Read" total="4" layout="3" width="wide"]

Newest posts from the same category. Leaves tags out:

[ruby_related heading="More in This Category" total="4" layout="1" where="category" order="date" width="wide"]

Posts that share a tag. Tags are usually narrower than categories, so these are closer to the post's topic:

[ruby_related heading="Related Articles" total="4" layout="2" where="tag" width="wide"]

On a post with no tags, where="tag" falls back to tags and categories.

Recently updated posts. For a site that keeps old articles up to date:

[ruby_related heading="Recently Updated" total="4" layout="1" order="modified" width="wide"]

Posts you choose yourself. Put your own post IDs in place of 101,102,103. They show in the order you type them:

[ruby_related heading="Start Here" ids="101,102,103" layout="2" width="wide"]

To find a post's ID, open it from Posts > All Posts: the number after post= in the address is the ID. post.php?post=345&action=edit is post 345.

A box with a thin border instead of a shadow:

[ruby_related heading="More Read" total="4" layout="1" style="border" width="wide"]

No heading and no frame. The posts only, blended into the text:

[ruby_related total="3" layout="4" style="plain" width="wide"]

The six layouts​

layoutWhat it shows
1the first post with a small thumbnail, the others as title links
2every post with a small thumbnail; at full width, each also shows its updated date
3the first post as a card with a large image, the others as title links
4 and 5titles only, no images. 4 is the compact one: a thin line between titles. 5 has no lines, more space between titles and, above phone width, more padding inside the box
6a grid of image cards, three per row, one per row on phones

A related box with layout="1" on a post, outlined in orange: the heading More Read above the first post with a small thumbnail, the other three as title links.

A related box with layout="2" on a post, outlined in orange: the heading More Read above every post with a small thumbnail and its date.

A related box with layout="3" on a post, outlined in orange: the heading More Read above the first post as a card with a large image, the other three as title links.

A related box with layout="4" on a post, outlined in orange: the heading More Read above four titles with no images, a thin line between them.

A related box with layout="5" on a post, outlined in orange: the heading More Read above four titles with no images and no lines, more space between them.

A related box with layout="6" on a post, outlined in orange: the heading More Read above image cards, three per row.

Any other number prints nothing at all.

Every parameter​

All parameters are optional. A parameter you leave out does not take the Related Posts - Ruby block's default; it takes the value in the last column.

ParameterWhat it doesValuesLeft out
headingthe title above the boxany textno title
totalhow many posts to showa number, at most 502
layoutthe look of the list1 to 61
wherewhich posts count as relatedall (same tags and categories), category, tagPosts from Where in Theme Options, which starts on Same Tags & Categories
orderthe order of the postsrand (random), date (newest first), modified (last updated)Order By in Theme Options, which starts on Random
idshand-picked posts instead of related onespost IDs separated by commasrelated posts
stylethe framedefault (shadow), border, plain (no frame)shadow
widththe size of the boxwide (full width), right (a column on the right)right for layouts 1 to 5, wide for layout 6
heading_tagthe HTML tag of the titleh1 to h6, p, div, spanh4 for layouts 1 to 3, h3 for 4 to 6
heading_layoutthe style of the title1 to 23, or c1 to c15 for centredTheme Options > Heading Design
post_idthe post the related posts are found froma post IDthe post the box is in

A few details:

  • width: right makes a column at most 350px wide on screens 768px and wider, with the text wrapping around it. On phones every box is full width. For most sites, use wide in the automatic box: it reads well wherever it lands.
  • total: capped by Theme Options > Performance > Query Limits > Max Posts Per Page, 50 by default. See Optimize Your Site Speed with Performance Options.
  • ids: takes over the whole query. The posts appear in the order you listed them, and total, where and order stop having any effect.
  • order: relevance is accepted but sorts like date, newest first. WordPress only sorts by relevance on a search.
  • where on a podcast episode: category means the episode's Shows.
  • post_id: almost always left out. Set it to show another post's related posts instead.

When the box does not show​

If no other post shares a category or a tag with the post, the box prints nothing rather than an empty frame. A missing box on one post usually means that. Add a category or tag the post shares with others, or use ids.