• I am using Underscores theme. And want to display featured or thumbnail post in first post only. Rest will be link as title.
    Anyone can help me. I am getting thumbnail images on all posts.
    Here is the index page code

    <?php
    $catquery = new WP_Query( 'cat=33&posts_per_page=4' ); 
    
            if ( have_posts() ) :
                if ( is_home() && ! is_front_page() ) :
            ?>
          
                    <header>
                        <h1 class="page-title screen-reader-text">
                            <?php single_post_title(); ?>
                        </h1>
                    </header>
                <?php
                endif;
            
                /* Start the Loop */ ?>
    
                    <?php  
                    while ($catquery->have_posts() ) :
                        $catquery->the_post(); ?>
    
                        <div class="card">
                            <?php
                            /*
                            * Include the Post-Type-specific template for the content.
                            * If you want to override this in a child theme, then include a file
                            * called content-___.php (where ___ is the Post Type name) and that will be used instead.
                            */
                            get_template_part( 'template-parts/home-content', get_post_type() );
                            ?>
     </div>
                        <?php endwhile;
        wp_reset_postdata();
    ?>
               
                <a href="#" class="btn btn-block btn-outline-success font-weight-bold more-cat" role="button">More form Cars & Bikes</a>
                <?php 
            else :
                get_template_part( );
    
            endif;
            ?>

    This is the template part home-content.php

    <?php
    /**
     * Template part for displaying posts
     *
     * @link https://developer.www.ads-software.com/themes/basics/template-hierarchy/
     *
     * @package Strap
     */
    
    ?>
    
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    
    <?php the_post_thumbnail();?>
    
    	<header class="entry-header">
    		<?php
    		if ( is_singular() ) :
    			the_title( '<h1 class="entry-title">', '</h1>' );
    		else :
    			the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
    		endif;
    
    		if ( 'post' === get_post_type() ) :
    			?>
    			<div class="entry-meta">
    				<?php
    				strap_posted_on('Last Updated on');
    				strap_posted_by();
    				?>
    			</div><!-- .entry-meta -->
    		<?php endif; ?>
        </header><!-- .entry-header -->
        
    	<footer class="entry-footer mb-2">
    		<?php strap_entry_footer(); ?>
    	</footer><!-- .entry-footer -->
    </article><!-- #post-<?php the_ID(); ?> -->
    • This topic was modified 6 years, 2 months ago by chandankus.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Only first post thumbnail of the posts’ is closed to new replies.