2

So, i got this code to retrieve the images inserted in a gallery within a post:

<?php
$args = array(
    'post_type' => 'attachment',
    'numberposts' => -1,
    'post_status'=>'inherit',
    'post_mime_type' => 'image',
    'post_parent' => $post->ID,
    'orderby' => 'menu_order',
    'order' => 'ASC'
);
$attachments = get_posts($args);
if ($attachments) {
    foreach ($attachments as $attachment) {
        $image_attributes = wp_get_attachment_image_src( $attachment->ID, 'full' );
        ?><img title="<?php echo $attachment->post_title; ?>" src="<?php echo $image_attributes[0] ?>" /><?php
    }
}
?>

and the output if fine, except that some pictures are duplicated and given a class="cloned" attribute.

This code is running within a basic loop:

<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>

with no extra special things before and after. This is happening locally and online as i wanted to be sure about this weird thing; here's the demo. If you inspect the code you'll see this:

<img class="cloned" src="http://k-win.fr/wptest/wp-content/uploads/2011/06/03mopi.jpg" title="03mopi">
<img src="http://k-win.fr/wptest/wp-content/uploads/2011/06/01.jpg" title="01">
<img src="http://k-win.fr/wptest/wp-content/uploads/2011/06/02.jpg" title="02">
<img src="http://k-win.fr/wptest/wp-content/uploads/2011/06/03mopi.jpg" title="03mopi">
<img class="cloned" src="http://k-win.fr/wptest/wp-content/uploads/2011/06/01.jpg" title="01">

But if you check the source code you wont see the class="cloned" i'm speaking of (devil inside!).

It's driving me a bit crazy cos it's messing up with the pictures order in some cases and this one has to be respected from the order decided in the gallery's options.

I checked with Opera, Chrome and Firefox, and all show me the same thing. Any clue?

1 Answer 1

1

that's your nivo-slider at work

2
  • True, it wasn't wordpress but the slider, which was not nivo but another one. I changed it and got it all working fine at last. Thanks a lot Piet.
    – kevin
    Jun 15, 2011 at 15:40
  • glad you got it working @kevin
    – user2015
    Jun 16, 2011 at 0:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.