I’m just modifying your code please check. Hope it will help.
<?php $args = array( 'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' => $post->ID,
'order' => 'ASC' );
$i = 0;
$attachments = get_posts($args);
if ($attachments) {
foreach ( $attachments as $attachment ) {
if($i != 0){
$class="fantome";
}else{ $class="";}
$imgarr = wp_get_attachment_image_src($attachment->ID,'full');
/*---------------this will output your image and class------- */
echo '<img class="'.$class.'" src="'.$imgarr[0].'" />';
$i++;
}
}
?>
Related Posts:
- Disable Attachment Pages Completely
- How to add a class to the attachment images
- Adding Featured Image to Post programatically
- Add custom field to attachments in a specific category
- Conditional Statement – check if post has an attachment image
- Upload images and attachments from frontend form
- Get a Page’s attachments in Gallery order
- Use Timber/Twig to pull an image by image ID [closed]
- File upload, uploads only file name
- page template for attachement page?
- is it possible to force wordpress to always save thumbnails as ‘jpg’ not ‘png’
- Link to the parent post in attachment page
- WordPress Search Results for Multiple Post Types
- Send multiple attachments with wp_mail in PHP
- Attach previously uploaded image to post – current code has unexpected results
- wp_mail file attachment not being placed in upload folder?
- Returning data instead of echoing/printing
- Find out last 7 days of upload images, last week uploaded image from Gallery and display them in different pages
- How to get the filename from file system and create a download link?
- how to get attached file url for current post?
- Front end file upload returning wrong attachment url
- Attaching images to posts manually (i.e. with custom code, without the use of an API)
- How to load previous or next attachment with jquery ?
- Add class to all img if they have a certain ACF field
- Problem with inserting multiple images in gallery of each WooCommerce product programmatically
- Unable to delete related media attachments with deleted post
- Attach and retrive multiple pdf files to post or page
- Get list of posts from attachment
- Get posts associated with media attachment
- File path for attachments outside of wp-content/uploads
- Attachments doesn’t update
- Post Title Not showing up
- Correct Syntax for uploading files to custom directory in WordPress
- How do I make a redirect in PHP?
- Retrieve POST data from AJAX call
- How to include external page to wordpress page?
- Facebook Comment Count
- How to overwrite youtube embed?
- How to resize image on client-side before upload?
- Filter the blog title displayed in the header
- Foreach insert query the best way
- How to generate page content from database the right way?
- How do I show the featured images for my child pages on my parent pages?
- dynamic php inside wordpress page
- Converting MYSQL to WordPress $WPDB
- WP_Query loop, does not display special characters in title correctly
- Get Admin Email Address From External PHP page
- How do I get current page ID in WordPress customizer file?
- How to run a php file that uses wordpress functions from command line?
- Was told to change the .htacess file form .html to .php so this would work properly
- Displaying Woocommerce Product Category in WordPress
- Split reads to a different connection string
- custom user role wordpress – grant guest access to edit.php without insert/update/delete
- How to make container class in PHP
- Copy taxonomy terms from one post to another programmatically
- Insert page content into another page with a changed variable
- Decimal values via get_option() with custom local (decimal point = comma)
- Is there a built-in function to generate multiple paragraph tags based on a string with new line separators?
- Site downloads files instead of loading them
- Saving data from custom form in wordpress database
- How to hide the author box of a specific user?
- Add date before entry title in Twenty Twelve
- Multidimensional Array
- Make post title active
- Where can I find linked fonts in my theme?
- Undefined variable: row?
- WordPress theme showing blank page
- How can I call a specific file (via php) by referencing the logged-in username?
- save_post action inside a custom metabox class not working
- quotes problem in very simple sql
- The additional fee for the COD payment method not visible in the front-end
- WordPress is removing query variables like page, p from the URL of a custom static page
- PHP identify duplicate words in a text string against a list of words
- Get the list of post categories
- Change extension to .jpg when webp is not supported
- How to add and subtract user meta values after post meta update
- how can i redirect dynamic URL in worpress base on ID in htaccess or wp-config or function.php
- Multiple AJAX handler functions conflict in functions.php
- HTTPS Just won’t render CSS
- Global variable doesnt’t pass to another function
- ACF values to Script with auto refresh
- PHP Error in WordPress Theme
- PHP 7.2 Challenge
- WordPress and WordPress-test-lib not getting added to tmp folder
- my_meta not saving in my current hosting
- Blog Image and Title in Right Sidebar
- Creating a WordPress addon for ContactForm7 submission (.XML file export)
- wordpress query returning unexpected results
- Singleton in plugin fails on AJAX call (Plugin initialzed again)
- How save data on user’s client cache
- How to always display full size image
- Updating Lat and Lng of posts automatically gives sporadic results
- Multilanguage website on two different domains
- White screen after login attempt
- Revision History for Entire WordPress Site
- How to access WOrdpress functions from within a class
- Custom query_posts() parameter
- Convert ACF checkbox choices to links [closed]
- How to modify this function to exclude also the post belonging to a specific category?
- AJAX WP_Query’s order and orderby parameters not working