• I have a products page, with multiple sub-pages. Each of the sub pages has a featured image.

    I want to query the products page by id or name, and display the featured images for each sub-page on my homepage.

    So I think it needs to be a loop of some kind, where it looks in

    I have looked around quite a bit and haven’t seen much like this. Any help is greatly appreciated as I am noob to php.

    This is what I currently have:

    <?php query_posts('post_type=page&post_parent=6'); ?>
        <?php while (have_posts()) : the_post(); ?>
        <div class="page_thumb">
    
       <!-- beginning thumbnail -->
       <div class="featured-image3">
        <?php
    		if ( has_post_thumbnail() ) {// the current post has a thumbnail
    		} else { // the current post lacks a thumbnail
    		}
    	?>
        <?php the_post_thumbnail(); ?>
            </div><!-- end thumbnail -->
       	</div>
        <?php endwhile; ?>

    thanks for any and all help

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter tjsherrill

    (@tjsherrill)

    Ok I got this to work in part.

    <?php query_posts(array('post_parent' => 6, 'post_type' => 'page')); while (have_posts()) { the_post(); ?>
    
            <div class="blind-subpage">
    
                <?php if ( has_post_thumbnail() ) {?>
    
                    <?php the_post_thumbnail(); ?>
    
                <?php } else { ?>
    
                    <!-- Else Don't show anything -->
    
                <?php } ?>
    
            <!-- closes blind-subpage -->
            </div>
    
        <?php } ?>

    Actually works fine, it grabs the post thumbnail just like I needed it to. The problem now is that I need it to also run a standard loop below that for the homepage text.

    <?php if (have_posts()) : while (have_posts()) : the_post();?>
     			<?php the_content(''); ?>
      		 <?php endwhile; endif; ?>

    Any ideas on how to run a second loop so that it displays the current page’s content. The first loop is overriding the page I think. I have read the support stuff for multiple loops but am to new to php to make great sense of it. Any help is greatly appreciated.

    thanks

    Thread Starter tjsherrill

    (@tjsherrill)

    And it figures that right after I ask this I would also find the solution.

    <?php wp_reset_query();?>

    Placed right after the initial query fixes the problem entirely.

    thnaks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Displaying sub page featured images on homepage’ is closed to new replies.