WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Showing thumbnails for first two posts only... (4 posts)

  1. tankmc
    Member
    Posted 1 year ago #

    Hi,

    I am stumbling around the PHP to build my theme but have come stuck on a small issue i'm hoping someone will know. I have thumbnails on my index page for each post, and i only want them to show for the first two.

    this i what i have so far but i am having trouble with the selector:

    <?php if ( ##SOMETHIGN HERE## ) : ?>
         <?php the_post_thumbnail(); ?>
    <?php endif; ?>

    Thank you in advance for your help.

  2. keesiemeijer
    moderator
    Posted 1 year ago #

    If this is inside a normal loop try:

    <?php if ($wp_query->current_post <= 1 ) : ?>
         <?php the_post_thumbnail(); ?>
    <?php endif; ?>
  3. tankmc
    Member
    Posted 1 year ago #

    Amazing that's perfect thank you!!

  4. keesiemeijer
    moderator
    Posted 1 year ago #

    You're welcome :-)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.