WordPress.org

Ready to get started?Download WordPress

Forums

Adding Image thumbnails to page navigation (1 post)

  1. lyeffeth
    Member
    Posted 4 years ago #

    I am using wp_list_pages to list my subpages in the sidebar. Each of these subpages are galleries (using SlidePress) and I would like to have a different thumbnail next to each page navigation link in addition to the page title. I've managed to add the image tag using the link_before argument for wp_list_pages and I think I can figure out how to make that image different for each page, but I don't want the parent pages to have thumbnails, just the sub-pages, and I am having trouble finding a conditional statement I can use to pick out just the subpages in the navigation.

    The following code is what I have so far:

    <?php 
    
    $image = //code here to select the image that matches the page.
    if this page link is a sub-page {
    $image_link = '<img src="'.$image.'" width="30" height="30" />';
    } else {
    $image_link = '';
    }
    $arguments = array(
    	'sort_column' => 'menu_order',
    	'title_li' => '',
    	'child_of' => '29', //29 is the ID of my main gallery page
    	'link_before' => $image_link,
    	);
    wp_list_pages($arguments);
    
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic