By $page->ID
, I guess you’re trying to fetch ID
of the current page, right? If so, that’s incorrect. Page itself is a post type so you need to get the ID through $post->ID
and make sure $post
is accessible otherwise use get_the_ID()
to return ID of the current post/page.
Final code:
<?php
$our_pages = get_pages( array( 'sort_column' => 'menu_order' ) );
foreach ($our_pages as $key => $page_item) :
$class="";
if($post->ID == $page_item->ID)
$class="current-item";
?>
<div class="menu-item <?php echo $class; ?>">
<a href="https://wordpress.stackexchange.com/questions/272111/<?php echo esc_url(get_permalink($page_item->ID)); ?>" class="menu-item-clicker">
<span><?php echo $page_item->post_title ; ?></span>
</a>
<?php echo get_the_post_thumbnail($page_item->ID,'full'); ?>
</div>
<?php endforeach; ?>