WordPress.org

Ready to get started?Download WordPress

Forums

Add class attributes to the li before ul.children in wp_page_menu (1 post)

  1. kongkang
    Member
    Posted 3 years ago #

    Below is my current menu structure.

    <div id="access">
      <div class="menu">
        <ul>
          <li class="current_page_item"><a title="Home" href="http://domain.com/">Home</a></li>
          <li class="page_item page-item-2"><a title="Sample Page" href="http://domain.com/sample-page/">Sample Page</a>
            <ul class="children">
              <li class="page_item page-item-4"><a title="Sub Page 1.1" href="http://domain.com/sample-page/sub-page-1-1/">Sub Page 1.1</a>
                <ul class="children">
                  <li class="page_item page-item-17"><a title="Sub Page 2.1" href="http://domain.com/sample-page/sub-page-1-1/sub-page-2-1/">Sub Page 2.1</a></li>
                  <li class="page_item page-item-19"><a title="Sub Page 2.2" href="http://domain.com/sample-page/sub-page-1-1/sub-page-2-2/">Sub Page 2.2</a></li>
                  <li class="page_item page-item-21"><a title="Sub Page 2.3" href="http://domain.com/sample-page/sub-page-1-1/sub-page-2-3/">Sub Page 2.3</a></li>
                </ul>
              </li>
              <li class="page_item page-item-13"><a title="Sub Page 1.2" href="http://domain.com/sample-page/sub-page-1-2/">Sub Page 1.2</a></li>
              <li class="page_item page-item-15"><a title="Sub Page 1.3" href="http://domain.com/sample-page/sub-page-1-3/">Sub Page 1.3</a></li>
            </ul>
          </li>
        </ul>
      </div>
    </div>

    Question

    How to add class attributes to the li.parent which has children. Example :

    <li class="<strong>parent</strong> page_item page-item-2"><a title="Sample Page" href="http://domain.com/sample-page/">Sample Page</a>
            <ul class="children">

Topic Closed

This topic has been closed to new replies.

About this Topic