How to give category priority to related articles in Luxeritas【Lexeritas】【WordPress】


Hello, this is Conomet.

Many of you using Luxeritas will also be using the “Related Articles" widget that comes standard with the theme.
You may have already noticed that this widget shows related articles by tags instead of by categories by default.

In this article, I’ll show you how to make the Related Articles widget in Luxeritas a CATEGORY priority!

The method

It’s easy to do!
You just need to rewrite one line of code from the file editor!

Let’s take a quick look at it below.

Look for “related.php"

Select the parent theme “Luxeritas"

First of all, let’s go to “Appearance" -> “Theme Editor" and select the parent theme “Luxeritas".

The following image should be easy to understand.

You can also choose “Luxeritas" from “Choose a theme to edit".

Find “related.php"

Next, let’s select “related.php" in the “theme file".
This file will be the main source of the “Related Articles" widget.

choose “related.php"

Rewrite the source code

When the above is done, all that’s left is to rewrite one line.

Code before change

Find the following one line in “related.php".

$post_in = array_unique( array_merge( $tag_post_id, $cat_post_id ) );

Code after change

Rewrite the previous code as follows.

$post_in = array_unique( array_merge( $cat_post_id, $tag_post_id ) );

I just swapped “$tag_post_id" and “$cat_post_id", but now it’s category priority!

Now all the work is done!
It was pretty easy.

If you’d like to give Luxeritas related articles a category priority, give it a try!

Sponsored Links