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条)

报告相同问题?

悬赏问题

  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决