Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
    
It will more help if you give example of which markup you want to achieve –  Ravs 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? –  Ravs Jun 5 '13 at 16:15
    
Same is fine... –  rowefx Jun 5 '13 at 18:25
    
check my answer below –  Ravs Jun 5 '13 at 18:41

1 Answer 1

up vote 0 down vote accepted

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

share|improve this answer
    
did you try this code? define link_before parameter in wp_list_pages.by doing that you get you required output. –  Ravs Jun 5 '13 at 18:39
    
Will be checking it soon and will update you. Thanks @Ravs. –  rowefx Jun 5 '13 at 19:47
    
Worked great thanks :) –  rowefx Jun 5 '13 at 21:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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