How to control the top bar TRENDING category (on Header & Navigation area) in Divi Extra Theme

How to control the top bar TRENDING category (on Header & Navigation area) on Divi Extra Theme?

The Trending section in your Extra WordPress theme is a great way to showcase popular or important posts at the top of your website. However, by default, it might pull random or most recent posts instead of the specific category you want to feature.

In this guide, we’ll show you how to control the Trending section by modifying the WordPress theme files to display posts from a specific category.

1. Log in to your WordPress Admin Panel.

2. Navigate to Appearance → Theme File Editor.

3. Open the theme-header.php file and open.

Add this following code just after line 48 like the image.

This is the code:

$header_vars[‘trending_posts’] = new WP_Query(array(

‘post_type’      => ‘post’,

‘posts_per_page’ => 5, // Number of trending posts

‘orderby’        => ‘date’, // Can change to ‘comment_count’ for most popular posts

‘order’          => ‘DESC’,

‘category_name’  => ‘your-category-slug’ // Replace with your actual category slug

));

How to Find Your Category Slug?

1. Go to WordPress Dashboard → Posts → Categories.

2. Locate the category you want to use.

3. Copy its Slug (e.g., technology, business, etc.).

4. Replace 'your-category-slug' in the code above with the actual slug.

5. Click Update File in the Theme Editor.

6. Clear any cache if you are using a caching plugin.

8. Refresh your website.

Your Trending section will now display posts only from the selected category! 🎉

If this isn't working for you or you're unable to do it yourself, feel free to contact me:

More articles for you