Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6095939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:52:08+00:00 2026-05-23T12:52:08+00:00

Im using wordpress and using the following to get the last 3 most recent

  • 0

Im using wordpress and using the following to get the last 3 most recent posts:

    <?php query_posts('showposts='.$latest_num.'&cat=-'.$featured_cat.','.$latest_ignore.''); ?>
    <?php while (have_posts()) : the_post(); ?>
    <li>
        <div class="imgholder">
            <a href="/wp-content/themes/twentyten/images/slide1.jpg" data-gal="prettyPhoto[featured]" title="<?php the_title(); ?>">
                <img src="<?php echo get_post_meta($post->ID, 'thumbnail',true) ?>" width="275" height="145" alt="Post Image" class="postimg-s" />
            </a>
        </div>
        <h4><?php the_title(); ?></h4>
        <p><?php the_content('Read more...'); ?></p>
    </li>
    <?php endwhile; ?>

What I want to do is add a class named 'last' to the <li> element on the 3rd interation through the loop.

Anyone got any ideas how I could add this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:52:09+00:00Added an answer on May 23, 2026 at 12:52 pm

    Li should be li

    <li <?php $iCounterLi++; ($iCounterLi==3)?'class="last"':''; ?>>
    

    Don’t forgot to initialize the $iCounterLi before the loop

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the following code to display a 'previous posts' link on my Wordpress
Using wordpress, I am pulling in a custom fields from specific posts to fill
Im using Wordpress, Im also creating posts via XMLRPC based on an RSS feed
I am hacking together a theme for Wordpress and I am using the following
I'm looking for the correct way of using wp_get_attachment_image(). The following code: <?php $args
I have a WordPress template that contains the following element: <html xmlns=http://www.w3.org/1999/xhtml <?php language_attributes('xhtml');
I am using WordPress's permalink structure %category%/%postname%/ with the following htaccess: <IfModule mod_rewrite.c> RewriteEngine
I'm following this tutorial to create custom Wordpress options the function within theme/functions/admin-menu.php which
I am trying to upload video to Wordpress.using following method string expression = videoData.VideoTitle;
I am using the following while loop inside an foreach-loop to get categories from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.