Support » Themes and Templates » Dynamic icons in wp_list_pages output

  • Hello everyone,
    Working away on one a template and I ran into a bit of a tricky situation (for me anyway).

    I have a sub-navigation down the left side of my page displaying child pages. I want to draw different navigation icons for the menu based on info entered in the post_meta. I figured it would have to be done by including the post_meta code in the LI output somehow but I’m not sure how to fuse the two, if possible.

    This is the code I’m using to display my child pages:

    <?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 id="subnav">
                 <?php echo $children; ?>
    <?php } else { ?>
    <?php } ?>

    And this is the code I would like to include into the LI output.

    <img src="<?php echo get_post_meta($post->ID, 'icon', true); ?>" alt="Featured Post" />

    Any and all help is possible. I’d like to do it without a plugin if possible, but will use as a last resort if necessary.

    Many thanks to anyone who can help!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Still haven’t figured this one out. Any help appreciated!


    Your thinking is not entirely off the mark, it would be great to use meta values when assigning icons to subpages, but unfortunately the wp_list_pages command does not output the meta value, only use this parameter to exclude or include pages from the list.

    I too am trying to find a way to include page icons with my page list, but for now it seems like it may not be easily accomplished!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Dynamic icons in wp_list_pages output’ is closed to new replies.