Output excerpt and thumbnail from custom archive page on front page

  • Unknown's avatar

    I have created a custom archive page, archive-winner.php that works as intended. However I would also like to display the 4 latest excerpt and thumbnail images from this archive on the index route, can anyone help me with the logic needed here?

    Many thanks in advance.

    <?php   
        get_header();
    ?>
    
    <div class="main-container container">
        <h1 class="winner-page page-title">Winners</h2>
            <div class="winners-row row">
                <?php if(have_posts()):?>
                <?php while(have_posts()) : the_post();?>
                <div class="winners-col col-12 col-md-6">
                    <div class="winners-inner-row row">
                        <?php if(has_post_thumbnail()):?>
                        <div class="winners-inner-col-1 col-12 col-lg-auto">
                            <div class="winner-img-container">
                                <img src="<?php the_post_thumbnail_url('post_image');?>" alt="<?php the_title();?>"
                                    class="winner-img" loading="lazy">
                            </div>
                        </div>
                        <?php endif;?>
                        <div class="winners-inner-col-2 col-12 col-lg-6 ">
                            <div class="winner-card">
                                <h3 class="winner-title"><?php the_title();?></h3>
                                <?php the_excerpt();?>
                            </div>
                        </div>
                    </div>
                </div>
                <?php endwhile ; else : endif;?>
            </div>
    </div>
    </div>
    
    </div>
    
    <?php   
        get_footer();
    ?>

    The blog I need help with is: (visible only to logged in users)

  • Unknown's avatar

    I solved this with a custom query, thanks!

  • Unknown's avatar
  • Hi there,

    Thanks for letting us know you figured it out.

    Just for future reference, the forums you posted in here is for the hosting provider, WordPress.com. We’re not the same thing as the open source WordPress software made on WordPress.org, and our volunteers and staff in this forum aren’t PHP developers.

    For help with custom WordPress development questions like this one, I recommend posting either to the advanced forum on WordPress.org, or alternatively you can ask in the WordPress Stackexchange forum:

    https://wordpress.org/support/forum/wp-advanced/

    https://wordpress.stackexchange.com/

  • The topic ‘Output excerpt and thumbnail from custom archive page on front page’ is closed to new replies.