/ Published in: PHP
                    
                                        
I don't recommend this, it just needed it for a particular situation. Does not work with dropdowns.
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
<?php
/* replace text nav with image nav */
/* match made by comparing page slugs to images in {template_directory}/images */
if ($post->post_parent || !$post->post_parent) { // in this case, I only want the subnav displayed on certain child pages - basically, show third-level on second-level
/*exclusion rules*/
//$exclude = implode(',',array('984')); //exclude page-id 984 from subnav
$toplevel = 'title_li=&depth=1&echo=0&exclude='.$exclude;
$siblings = $toplevel.'&child_of='.$post->post_parent;
pause_exclude_pages();
$links = ($post->post_parent) ? wp_list_pages($siblings) : wp_list_pages($toplevel);
resume_exclude_pages();
}
else {
$links = ($post->post_parent) ? wp_list_pages($siblings) : wp_list_pages($toplevel);
}
function addback(&$input) {
$orig = $input;
$anchortext2 = '>'.$anchortext.'<';
$img = '<img src="' . get_bloginfo('template_directory') . '/images/' . $slug . '.jpg" />';
$newtext = $img;
$newtext = '>'.$newtext.'<';
$input = '<li'.$input.'</li>'; //put them back for handling
}
}
/* end replace text nav with image nav */
?>
URL: http://trepmal.com/scripts/image-replacement-for-wp_list_pages/
Comments
 Subscribe to comments
                    Subscribe to comments
                
                