modifying wp_list_pages() to use image for title
-
this function :
wp_list_pages();lists my pages in this format :Pages page1 page2 page3Well , i dont want it to show me the word “Pages“. Instead of “Pages” i want to add an image.
Image page1 page2 page3I dont know where to edit. I selected the sidebar.php from the editor and there i have
<?php wp_list_pages(); ?>but i cannot edit it from there. I want to get rid of “Pages” and use<img src="image.gif">istead. I think i must edit some other files to make this possible.My screenshot explains the problem. I added an image for Categories, one for Search and one for Archive, but i cannot add an image to Pages.
http://img386.imageshack.us/img386/402/57980632qn0.jpg
Can you help ? Thanks.
-
Did you already edit the sidebar.php file to add those other images in there?
The word “Pages” in your screenshot should be just above the
<?php wp_list_pages(); ?>in the sidebar.php. Is it not there?Can you post the sidebar.php file or give me the URL to it so I can look at it?
well , the word “Pages” isnt there.
This is the sidebar.php from the theme.
<!-- begin sidebar --> <div id="menu"> <ul> <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?> <?php wp_list_pages(); ?> <li id="categories"><img src="http://www.voievozii.ro/categorii.gif"> <ul> <?php wp_list_cats(); ?> </ul> </li> <li id="search"> <label for="s"><img src="http://www.voievozii.ro/cauta.gif"></label> <form id="searchform" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <div> <input type="text" name="s" id="s" size="15" /><br /> <input type="submit" value="<?php _e('Cauta !'); ?>" /> </div> </form> </li> <li id="archives"><img src="http://www.voievozii.ro/arhiva.gif"> <ul> <?php wp_get_archives('type=monthly'); ?> </ul> </li> <?php endif; ?> </ul> </div> <!-- end sidebar -->To add an image at the top of your page listing:
<?php wp_list_pages(‘title_li=’. __(‘<img src=”image.gif”>’)); ?>To use a random image :
<?php
$tab = array(
‘<img src=”image1.gif”>’,
‘<img src=”image2.gif”>’,
‘<img src=”image3.gif”>’);
wp_list_pages(‘title_li=’. __($tab[rand(0,2)]));
?>thanks a lot man. i apreciate.
Woman! arghhh!
Thanks Roya!
One more quick question – what if I wanted the image name to be a meta_value for each post instead of a hard coded image name?
Thanks in advance?
The topic ‘modifying wp_list_pages() to use image for title’ is closed to new replies.