Support » Fixing WordPress » Query Page Thumb Outside the Loop

  • I have this funky custom job where page title and post thumb are on the left, and the content is on the right.

    Im stuck on the thumbnail query.

    The following works for the page title, but I cant find the method for getting the thumb this way.

    <?php global $post;
    $page_title = $wp_query->post->post_title;
    echo $page_title;
    ?>

    The following works to get the thumb, but it gets ALL the thumbnails, not the current page thumbnail.

    <?php
    $query = new WP_Query( array( 'post_type' => 'page' ) );
    while ($query->have_posts()) : $query->the_post(); ?>
    <?php the_post_thumbnail('hosts'); ?>
    <?php endwhile; ?>

    does anyone know how to get the current page thumbnail outside the loop? Ive looked everywhere.

Viewing 1 replies (of 1 total)
  • get the id of post from loop with this get_the_id();
    and insert thumbnail code <?php echo get_the_post_thumbnail(36); ?>
    36 is the id of your post change it

Viewing 1 replies (of 1 total)
  • The topic ‘Query Page Thumb Outside the Loop’ is closed to new replies.