Title: Get Post Thumbnails for custom menu
Last modified: August 30, 2016

---

# Get Post Thumbnails for custom menu

 *  Resolved [Beatsleigher](https://wordpress.org/support/users/beatsleigher/)
 * (@beatsleigher)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/get-post-thumbnails-for-custom-menu/)
 * Hi there,
 * I’m currently designing my website, and I thought a custom theme is the way to
   go, so I can implement my ideas as I wish.
 * I mocked up the website as I want it to be (see here: [https://lh3.googleusercontent.com/E5kOO142XCj4DcX0t_SgIJ0HpOFQMndiXscsuDWKylU=w1440-h900-rw](https://lh3.googleusercontent.com/E5kOO142XCj4DcX0t_SgIJ0HpOFQMndiXscsuDWKylU=w1440-h900-rw)),
   however that is just a static mockup to see how I want the website to look like(
   at least the left).
 * Now I want to make things automatic. I have a page structure which will be used
   to put everything in the right order (and new categories for the menu can be 
   easily added).
 * So far, I’ve got the pages listed in the order I want; however, I can’t seem 
   to be able to load the featured images (thumbnails).
 *     ```
       <!DOCTYPE html >
       <!-- <div class="left-separator" ></div> -->
       <html >
       	<?php
       	$post = NULL;
       	$defaults = array(
       		'child_of' => 0, 'sort_order' => 'ASC',
       		'sort_column' => 'post_date', 'hierarchical' => 1,
       		'exclude' => array(), 'include' => array(),
       		'meta_key' => '', 'meta_value' => '',
       		'authors' => '', 'parent' => -1, 'exclude_tree' => array(),
       		'number' => '', 'offset' => 0,
       		'post_type' => 'page', 'post_status' => 'publish',
       	);
   
       	$pages = get_pages($defaults);
       	//var_dump($pages);
       	foreach ($pages as $page) {
       		if ($page->post_parent === 0) {
       			// Page is a parent, only has children.
       			// Only do stuff here, ignore the rest...
       			//var_dump($page); die();
       			$id = $page->ID;
       			$children = get_page_children($id, $pages);
       			//var_dump($children);
       			$_children = "";
       			$thumbnail = get_the_post_thumbnail($id);
   
       			foreach ($children as $child) {
       				$_children .= "<li >";
       				$_children .= $child->post_title;
       				$_children .= "</li>";
       			}
   
       			$html =
       			"
       				<div class='left-menu-container' >
       					<ul >
       						<li >
       							$page->post_title
       							<ul >
       								$_children
       							</ul>
       						</li>
       					</ul>
       				</div>
       				<div class='left-separator' ></div>
       			";
       			echo $html;
       		} else continue;
       	}
       	?>
       </html>
       ```
   
 * That is my code; it’s based off of the code I used to get the posts on the homepage,
   which works perfectly fine.
 * Now, to describe the problem a bit more accurately; if I use _get\_the\_post\
   _thumbnail($id)_, I don’t get any image at all.
    If, however, I use _the\_post\
   _thumbnail($id)_, I get my little test piggy, which I used to test the post slider.
 * Has anyone experienced this before, and is there a way around it?
 * Thanks a lot in advance for any help!
 * Website for previewing is: [https://www.ca-softworks.com/?loadPreview=1](https://www.ca-softworks.com/?loadPreview=1)

Viewing 1 replies (of 1 total)

 *  Thread Starter [Beatsleigher](https://wordpress.org/support/users/beatsleigher/)
 * (@beatsleigher)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/get-post-thumbnails-for-custom-menu/#post-6772471)
 * I have no idea what it did, but it all of a sudden started to work.
 * Case closed.

Viewing 1 replies (of 1 total)

The topic ‘Get Post Thumbnails for custom menu’ is closed to new replies.

## Tags

 * [menu](https://wordpress.org/support/topic-tag/menu/)
 * [page](https://wordpress.org/support/topic-tag/page/)
 * [pages](https://wordpress.org/support/topic-tag/pages/)
 * [post](https://wordpress.org/support/topic-tag/post/)
 * [posts](https://wordpress.org/support/topic-tag/posts/)
 * [thumbnails](https://wordpress.org/support/topic-tag/thumbnails/)

 * 1 reply
 * 1 participant
 * Last reply from: [Beatsleigher](https://wordpress.org/support/users/beatsleigher/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/get-post-thumbnails-for-custom-menu/#post-6772471)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
