0

In a wordpress theme, I am using the wp_list_pages() function to generate the list of pages and its working great however I need help making one of the links redundant.

This is what wp_list_pages is outputting and the one that I need to change:

<li class="page_item page-item-12"><a href="http://mysite.com/page3">Page 3</a>
  <ul>
    <li><a href="http://mysite.com/page4">Page 4</a></li>
  </ul>
</li>

I would like this to be

<li class="page_item page-item-12">Page 3 
 <ul>
  <li><a href="http://mysite.com/page4">Page 4</a></li>
 </ul>
</li>

This is the JQuery that I am using:

 <script>
 $(document).ready(function() {

 $(".page-item-12 a").removeAttr("href");
 });
 </script>

However, the Jquery is removing the links from all the < li > in the child ul as well which I do not want.

Thanks in advance.

4

2 回答 2

1
<script>
    $(document).ready(function() {
    $(".page-item-12 > a").removeAttr("href");
     });
</script>
于 2013-08-19T09:04:00.280 回答
0

如果有人需要修复,我找到了一个:

<script>
$(document).ready(function() {
$(".page-item-12 a").removeAttr("href");
});
</script>

然而有一个新的问题。如果有子页面,它也会断开它们的链接:( - 我该如何阻止它?

于 2013-08-19T09:06:50.617 回答