
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! 🎉
More articles for you
What Makes WordPress an Excellent Choice for Building Websites in 2025?
WordPress remains a top choice for creating websites in 2025 for several key reasons: User-Friendly Interface: WordPress offers an intuitive interface, making it accessible to beginners and non-technical users. Its visual editors like Gutenberg provide a drag-and-drop experience, simplifying the content creation process. Extensive Customization: With thousands of themes and…
Shopify Vs. WordPress WooCommerce: Which One is Better for Startup or Small Business?
When you’re a startup or small business owner looking to set up an e-commerce website, choosing the right platform is a critical decision that can impact your business’s growth and scalability. Shopify and WordPress WooCommerce are two of the most popular e-commerce platforms, each with distinct features, benefits, and drawbacks.…