Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7846135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:28:36+00:00 2026-06-02T17:28:36+00:00

WordPress outputs my child menus inside this ul tag… <ul class=sub-menu> how can I

  • 0

WordPress outputs my child menus inside this ul tag…

<ul class="sub-menu">

how can I wrap a simple div around it?

Preferably a way to do it through functions.php, but jquery can work too.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T17:28:37+00:00Added an answer on June 2, 2026 at 5:28 pm

    While it would be EASY to use something like jQuery to wrap your child menus, it is NOT good practice to use jQuery for this purpose. Place this in functions.php:

    class Child_Wrap extends Walker_Nav_Menu
    {
        function start_lvl(&$output, $depth = 0, $args = array())
        {
            $indent = str_repeat("\t", $depth);
            $output .= "\n$indent<div class=\"custom-sub\"><ul class=\"sub-menu\">\n";
        }
        function end_lvl(&$output, $depth = 0, $args = array())
        {
            $indent = str_repeat("\t", $depth);
            $output .= "$indent</ul></div>\n";
        }
    }
    

    I’m assuming that your menu is being generated in your header, so go to header.php (or whatever file is utilizing the wp_nav_menu function) and look for anything that starts with “wp_nav_menu”.

    Since I don’t have any code to see, I can only guess the arguments that it’s using (if any). If it looks EXACTLY like “wp_nav_menu()” with nothing in between the parenthesis, then change it to the following:

    wp_nav_menu(array('walker' => new Child_Wrap()))
    

    Otherwise, please edit your question with the code that your menu is using so I can help you further.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Wordpress wraps images with captions in a div with a class of .wp-caption. I'm
Wordpress has a filter that automatically add paragraphs to posts. I can remove this
Example of WordPress default CSS class output: <li id=menu-item-55 class=menu-item menu-item-type-post_type menu-item-object-page menu-item-55> <li
I am trying to build a menu in Wordpress that will look like this
WordPress allows theme designers to place a 404.php file in their theme's directory. This
Wordpress ships with the wpdb class which handles CRUD operations. The two methods of
I'm using a loop in wordpress to output posts. I want to wrap every
in wordpress i have a query where it queries specific posts. <div id=container-> <?php
Can you tell me your opinion of this, and possibly see if you can
I have a very strange problem that I can't wrap my head around... I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.