Setting "Include in Navigation Menu" for All Categories to Yes

Stefan Bogdanescu
Founder & Senior Architect · 17 September 2026

As a senior developer specializing in Laravel, I often encounter questions about managing categories within an e-commerce platform. One common query involves updating the Include in Navigation Menu value for all product categories to Yes. Let’s dive into the database schema and provide a step-by-step guide to accomplish this task efficiently.

Understanding the Database Structure

In a typical Laravel application using the WooCommerce plugin, category data is stored in the wp_terms table. However, the Include in Navigation Menu setting isn’t found directly in this table. Instead, it’s managed through the wp_term_taxonomy table, which links terms to their respective taxonomies.

The relevant columns for our task are:

  • term_id: The unique identifier for the category.
  • taxonomy: Set to ‘product_cat’ for product categories.
  • description: Stores a serialized array containing metadata about the category, including the navigation menu status.

Updating “Include in Navigation Menu” Status

To update the navigation menu status for all categories, we need to deserialize the description field, modify the menu_order key (which corresponds to this setting), and then serialize it back. Here’s a practical example using MySQLi:

<?php
// Assuming you have an active WooCommerce database connection

$query = "SELECT term_id, description FROM wp_term_taxonomy WHERE taxonomy='product_cat'";
$result = mysqli_query($connection, $query);

while ($row = mysqli_fetch_assoc($result)) {
    // Deserialize the description field
    $meta = unserialize($row['description']);

    if (isset($meta['menu_order'])) {
        // Set menu_order to 0 for 'Include in Navigation Menu' = Yes
        $meta['menu_order'] = 0;
    }

    // Serialize and update the description field with the modified metadata
    mysqli_query($connection, "UPDATE wp_term_taxonomy SET description='".mysqli_real_escape_string($description, serialize($meta))."' WHERE term_id=".$row['term_id']);
}

This script retrieves all product category IDs (term_id), deserializes their associated metadata, updates the menu_order key to 0 (indicating that the category should be included in the navigation menu), and then serializes the updated metadata back into the database.

Best Practices and Additional Considerations

While this solution is effective for small to medium-sized stores, it’s not recommended for extremely large databases due to performance implications. Instead, consider using Laravel’s built-in query builder or the WooCommerce Database API for a more efficient approach that leverages prepared statements and proper error handling.

Also, always remember to backup your database before making global changes like this. It’s crucial to ensure you can revert any unintended modifications if needed.

Conclusion

Setting the Include in Navigation Menu value for all product categories to Yes involves navigating through the WooCommerce database schema and updating serialized metadata fields. By understanding the underlying data structure and using appropriate PHP functions, we can achieve this task efficiently while maintaining a clean and organized codebase.

Remember, LaravelCompany offers comprehensive guides on Laravel development and WooCommerce integration, which are excellent resources for expanding your knowledge in this area.

Our network