new WP_Query from multible categories and featured image only in the 1st post (1 post)

  1. panism
    Posted 3 years ago #

    I have a problem getting the featured image only from the first post.
    I have a custom query which takes latest 3 posts from 4 categories. Until now i manage to grab the featured image for all the posts, but i want the featured image to show only in the first post. The other two just the title. Also each category with the first post with the featured image and the titles to be displayed in one div. Right now as it is, i get 12 posts in 12 divs. Here is my code. Thanks in advance.

    [ Moderator Note: Please post code or markup snippets between backticks or use the code button. ]

    <div id="home_page_main_posts">
                            $taxonomy = 'category';
                            $param_type = 'category__in';
                              'include' => '4,5,6,7',
                              'orderby' => 'name',
                              'order' => 'ASC'
                            $terms = get_terms($taxonomy,$term_args);
                            if ($terms) {
                              foreach( $terms as $term ) {
                                  "$param_type" => array($term->term_id),
                                  'post_type' => 'post',
                                  'post_status' => 'publish',
                                  'posts_per_page' =>3,
                                  'caller_get_posts'=> 1
                                $my_query = null;
                                $my_query = new WP_Query($args);
                                if( $my_query->have_posts() ) {
                                  while ($my_query->have_posts()) : $my_query->the_post(); ?>
                                    <div class="post_home_main">
                                    <!--  Add timthumb to post featured image -->
    								$image_id = get_post_thumbnail_id();
    								$image_url = wp_get_attachment_url($image_id);
    								if ($image_url) {
    								<img src="<?php bloginfo('template_directory'); ?>/scripts/timthumb.php?src=<?php echo $image_url; ?>&w=196&h=115&q=1000" alt="<?php the_title();?>" />
                                     <!--  // Add timthumb to post featured image -->
    								<?php } else { ?>
                                    <img src="<?php echo bloginfo('template_directory') . '/images/no-image.jpg'; ?>" alt="No image available" class="panikosule" />
                                    <?php } ?>
                                    <a>" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
                                    <?php the_excerpt(); ?>
                            wp_reset_query();  // Restore global post data stomped by the_post().
    <span class="arrow"></span> </div><!-- //home_page_main_posts -->

Topic Closed

This topic has been closed to new replies.

About this Topic