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 7167241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:32:46+00:00 2026-05-28T14:32:46+00:00

I am using the code below to get the attached images for each post

  • 0

I am using the code below to get the attached images for each post in my theme for use in a slideshow. It works great in that it is able to retrieve all of the attached images, but it also includes the post thumbnail.

So my question is, is there a way to exclude just the featured_image but display the rest of the images?

PHP

function bdw_get_images($postId) {

$iPostID = $postId;
$arrImages =& get_children('post_type=attachment&post_mime_type=image&post_parent=' . $iPostID );

    if($arrImages) {

        $arrKeys = array_keys($arrImages);

        foreach($arrImages as $oImage) {
            $arrNewImages[] = $oImage;
        }

        for($i = 0; $i < sizeof($arrNewImages) - 1; $i++) {
            for($j = 0; $j < sizeof($arrNewImages) - 1; $j++) {
                if((int)$arrNewImages[$j]->menu_order > (int)$arrNewImages[$j + 1]->menu_order) {
                    $oTemp = $arrNewImages[$j];
                    $arrNewImages[$j] = $arrNewImages[$j + 1];
                    $arrNewImages[$j + 1] = $oTemp;
                }
            }
        }

        $arrKeys = array();

        foreach($arrNewImages as $oNewImage) {
            $arrKeys[] = $oNewImage->ID;
        }

        $iNum = $arrKeys[0];

        foreach( $arrKeys as $key) {
            $sImageUrl = wp_get_attachment_url($key);
            $sImgString = '<img src="' . $sImageUrl . '" alt="Thumbnail Image" />';
            echo $sImgString;
        }
    }
}

bdw_get_images($post->ID);
  • 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-28T14:32:47+00:00Added an answer on May 28, 2026 at 2:32 pm

    Get post thumbnail(if any) by get_post_thumbnail_id( $post_id ) function and check against it in the last loop.
    So the last loop should look like this:

    $post_thumbnail_id = get_post_thumbnail_id( $iPostID );
    foreach( $arrKeys as $key) {
        if( $key == $post_thumbnail_id )
            continue;
        $sImageUrl = wp_get_attachment_url($key);
        $sImgString = '<img src="' . $sImageUrl . '" alt="Thumbnail Image" />';
        echo $sImgString;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using this code, and I get the stack trace that is listed below.
i using below code to get a picture from URL: URL url=new URL(http://www.google.com/images/logos/ps_logo2.png); InputStream
I'm using code below to get JSON data: [AcceptVerbs(HttpVerbs.Get)] public JsonResult getBranchViaJson() { Json(getBranchList(AppSession.BranchID.Value));
I try to use the code as below to get the website htm source
I am using the following code below to get the price from the attribute
I am using the code below to get information from a database and make
Using the code below I can't get the image in the web page. I'm
I am using the code shown below to get Data from our server where
I am using below code to get & process value from google HashMultimap HashMultimap
Using the code below, I am returning an nvarchar field from MS SQL 2005

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.