Miker
Miker

Reputation: 194

Wordpress: feaured images into menu

Merry Xmas to everyone BTW.

On some pages I am including featured images (which are being output into 2 different sizes, 200px x 200px and 40px x 40px.

My goal is to show the 40 x 40 featured images appear in the wordpress menu whenever a page has a featured image attached to it. For example:

<ul>
    <li><a href=""><img src="featured-image-01" alt="" />This is menu item 01</a></li>
    <li><a href=""><img src="featured-image-02" alt="" />This is menu item 02</a></li>
    <li><a href=""><img src="featured-image-03" alt="" />This is menu item 03</a></li>
</ul>

etc.

The problem is the common code used to generate the wordpress menu...

<?php wp_list_pages('title_li=&sort_column=menu_order'); ?>

... doesn't allow for this.

If anyone can help me solve this problem it will be a late but great xmas present for me :-)

Cheers.

Upvotes: 0

Views: 675

Answers (1)

tamilsweet
tamilsweet

Reputation: 1007

You can use the get_pages function.

<?php
$pages = get_pages( 'sort_column' => 'menu_order' );

if($pages) {
    echo '<ul>';
    foreach($pages as $page) {
    ?>
        <li><a href="<?php get_permalink($page->ID);?>"><?php the_post_thumbnail( array (40,40) );?><?php echo $page->post_title;?></a></li>
<?php
    }
    echo '</ul>';
}

Upvotes: 1

Related Questions