0

I'm wanting to custom style the output of this wp_list_pages $children echo, here is the code:

<?php
if($post->post_parent)
  $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
else
  $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
if ($children) { ?>
<ul class="submemu-children">
  <?php echo $children; ?>
</ul>
<?php } ?>

As you can see I've already added a class to the UL, but what if I want to dig a little deeper and add some markup around the $children in the echo? Any help is greatly appreciated. Thank you!

I would like to achieve something like the following:

<ul class="submenu-children">
<li><i class="icon-something"></i><a href="#">Link</a></li>
<li><i class="icon-something"><a href="#">Link</a></li>
<li><i class="icon-something"><a href="#">Link</a></li>
<li><i class="icon-something"><a href="#">Link</a></li>
<li><i class="icon-something"><a href="#">Link</a></li>
</ul>

I've temporarily appended the makrup through jQuery, but I would like to know for future reference ideally.

  • It will more help if you give example of which markup you want to achieve – Ravinder Kumar Jun 5 '13 at 15:58
  • Sure will add now :) – rowefx Jun 5 '13 at 16:03
  • do you want all "<i class="icon-something"></i>" diffrent? – Ravinder Kumar Jun 5 '13 at 16:15
  • Same is fine... – rowefx Jun 5 '13 at 18:25
  • check my answer below – Ravinder Kumar Jun 5 '13 at 18:41
0

try this

$children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0&link_before=<i class="icon-something"></i>');

define link_before property in wp_list_pages

  • did you try this code? define link_before parameter in wp_list_pages.by doing that you get you required output. – Ravinder Kumar Jun 5 '13 at 18:39
  • Will be checking it soon and will update you. Thanks @Ravs. – rowefx Jun 5 '13 at 19:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.