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

  • Home
  • SEARCH
  • 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 8847511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:12:24+00:00 2026-06-14T12:12:24+00:00

I have a gallery which should display 3 columns, the first two columns have

  • 0

I have a gallery which should display 3 columns, the first two columns have a certain class and work absolutely fine but I am trying to add a “last class” to my third column – for some reason it’s not working. Find my code below:

        <?php 

        $mod =1;
        if ( $images = get_posts(array(
           'post_parent' => $post->ID,
           'post_type' => 'attachment',
           'numberposts' => -1,
           'post_mime_type' => 'image',)))

        {

         foreach( $images as $image ) {

         $attachmenturl=wp_get_attachment_url($image->ID);
         $attachmentimage=wp_get_attachment_image_src( $image->ID, full );
         $imageDescription = apply_filters( 'the_description' , $image->post_content );
         $imageTitle = apply_filters( 'the_title' , $image->post_title );
             if ($mod % 3 == 0) {
            $class = "gallery-entry-img-last";
             }else{
            $class = "gallery-entry-img";
            }
         echo '<div class="'.$class.'"><div class="gallery-entry-img-l"><a rel="next" href="' . $attachmentimage[0] . '"><span class="rollover" ></span><img src="library/tools/timthumb.php?src=' . $attachmentimage[0] . '&amp;w=270&amp;h=198" alt="" /></div></div>';
         }
         $mod++;
        }     
        else {
             echo "No Image";
        }



         ?>

Some expert advise would be greatly appreciated.

  • 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-06-14T12:12:26+00:00Added an answer on June 14, 2026 at 12:12 pm

    increment your $mod variable inside foreach loop, like:

    foreach(.....) {
     ......
     $mod++;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a class which extends Gallery. There is no onCreate() method in
I have a application which handles picture chosen from gallery. But there is a
I have to do android app which includes Gallery with GridView and images should
I have made a php image gallery, which should list all the subdirectories of
I have a slide gallery which adds a class curSlide to an image when
I have a javascript for gallery which works well. When i click a picture
I have a small self made gallery which im still working on it: http://springbreak.enteratenorte.com
what i want to do is that i have a nice image Gallery which
Hi I have a gallery in my app which shows the image in an
I have the video gallery in my database, which has over 200 000 videos.

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.