Wordpress Featured Images for Pages

93 views Asked by At

I am attempting to make a masonry gallery page with featured images for PAGES not posts. I already have my masonry grid which is displaying perfectly. The current php loads posts in the masonry grid. I just cannot figure out how to get featured images of PAGES to load.

Here is the php for the page template

<?php
    $temp = $wp_query;
    $wp_query= null;
    $wp_query = new WP_Query();
    $wp_query->query('posts_per_page=100'.'&paged='.$paged);
    while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
        <div class="brick">
            <div class="brick_featured_image">
                <?php if ( has_post_thumbnail() ) {
                    $size=75;
                ?>
                <a href="<?php the_permalink() ?>" rel="bookmark" title="Click to view: <?php the_title_attribute(); ?>">
                    <?php the_post_thumbnail( $size );  }  ?>
                </a>
            </div>
        </div>
    <?php endwhile;?>
<?php $wp_query = null; $wp_query = $temp;?>
<!-- stop The Loop. -->
</div><!-- container -->
<?php get_footer(); ?>
1

There are 1 answers

2
KatS On BEST ANSWER

If the code works ok otherplaces, Replace $wp_query = new WP_Query() with

    `$wp_query = new WP_Query('post_type=page')`

If you continue to have problems, you could try renaming wp_query ie

$your_query = new WP_Query('post_type=page')

while ($your_query->have_posts()) : $your_query->the_post();