douzhiling3166 2016-02-23 07:08 采纳率: 100%
浏览 79
已采纳

将Bootstrap类/样式添加到Wordpress wp_list_pages菜单项

I have some code that generates a sidebar menu on my Wordpress site as below...

<ul>
    <?php
    if($post->post_parent)
        $children = wp_list_pages("title_li=&sort_column=menu_order&child_of=".$post->post_parent."&echo=1");
    else
        $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=1");
        if ($children) { ?>
            <?php echo $children; ?>
        </div>
    <?php } ?>
</ul>

This outputs code in the following way...

<ul>
    <li class="page_item page-item-94 current_page_item"><a href="#">Menu Item</a></li>
</ul>

The problem is, I need it to use my Bootstrap 3 styles and output the list as below...

<div class="list-group submenu">
    <a href="#" class="list-group-item">Menu Item</a>
</div>

Basically I need to add the class of list-group-item to the a tag in the output list items. Is that at all possible?

  • 写回答

2条回答 默认 最新

  • duancanjiu3754 2016-02-23 07:26
    关注

    You can do this through jquery

    $(document).ready(function(){
        $("ul").find("li").each(function(){
          $(this).addClass("YourClass");
        })
    })
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?