• I set up a custom post type. I only want one post from that post type to show on the homepage. But I want all featured images from every post in that type to show up on the homepage. How can I accomplish this?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    try query post or get post to do multiple loops. show 1 post of the custom post type on the first loop and do a second loop to show al your featured images

    Thread Starter cybershot

    (@cybershot)

    I will give that a shot

    Thread Starter cybershot

    (@cybershot)

    well, I am running into trouble. Take a look. Do you have any advice on it?

    
    
    <?php $args = array('post_type' => 'half slider');
    				$loop = new WP_Query($args);
    					while($loop->have_posts() ) :
    						 $loop->the_post_thumbnail('half_slider');
                   		endwhile; ?>
    Moderator keesiemeijer

    (@keesiemeijer)

    try for your first loop:

    <?php
    $args = array('post_type' => 'half slider', 'posts_per_page' => 1);
    $loop = new WP_Query($args);
    ?>
    <?php while ( $loop->have_posts() ) : $loop->the_post() ?>
    <?php
    if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
      the_post_thumbnail();
    }
    ?>
    
    <?php  the_content(); ?>
    <?php endwhile; ?>

    Thread Starter cybershot

    (@cybershot)

    nope. it’s not working. there is a syntax error somewhere in there so I can’t test it because I can’t find it. I don’t think it would work anyway. I am trying to set it up so that when the user creates a post, the excerpt will show on the left side of the page. Which I have set up now. And then the featured image will show up on the right side of the page. But I am trying to load the featured image into the Nivo slider. The problem is that when you create a new post to add a new featured image, it wants to overwrite the post on the left. Which I don’t want. So your idea of two loops was a good one. So I have been looking for ways to query the ‘half slider’ post type and get just the featured images from that post type to load them into the slider.

    Moderator keesiemeijer

    (@keesiemeijer)

    well, good luck in your quest

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘how do I query the featured image?’ is closed to new replies.