This members-only tutorial provides the steps to add a section on single posts to display 4 random posts (excluding the current one) in the same category/categories as the current post for a custom "related posts" functionality in Oxygen.

We shall add the PHP code for this in a Code Block to

  1. retrieve the current post's categories
  2. store the array of category IDs in a variable
  3. get comma-separated category IDs in a variable
  4. write a WP_Query arguments array
  5. write a basic loop to show post titles

and finally replace the above loop with PHP and CSS from the default Easy Posts component's preset.

Step 1

Edit the Template that applies to single blog posts with Oxygen.

Add a Section.

Add a Code Block inside.

PHP & HTML:

This is a premium members-only content.

To view the rest of the content, please sign up for membership ($27/month).

Already a member? Log in below or here.

Need help implementing a tutorial in your site or want to hire me for custom work?

HIRE ME

Find the article helpful and wish to donate?

DONATE

Comments

For adding code blocks wrap the code in three backticks. Markdown should work.
Provide a URL of your site/webpage if something is not working.
magnifiercross
>
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram
%d bloggers like this: