Showing images attached to a page contains media g

2019-08-01 12:18发布

I'm using Wordpres Bootstrap that by default doesn't show images from the galleries (default media gallery of wp). I simply want to show the images from a gallery as the default WordPress does. I'm trying a script that works but it shows ALL the images uploaded in Media Library and not the only ones attached to the single page. I'm going crazy with this from 3 days, without find solution! :(

<ul>
<?php $images = get_children('post_type=attachment&post_mime_type=image&post_parent=' . $post->ID . ' &orderby=menu_order&order=ASC');
foreach( $images as $img_id => $img_r ) :
     $thumb = wp_get_attachment_image_src( $img_id, 'thumbnail', true );
     $full = wp_get_attachment_image_src( $img_id, 'full', true ); ?>
     <li>
        <a href="<?php echo $full[0] ?>">
             <img src="<?php echo $thumb[0] ?>" alt="<?php echo get_the_title( $img_id ) ?>" title="<?php echo get_the_title( $img_id ) ?>">
        </a>
     </li>

<?php endforeach; ?>
</ul>

0条回答
登录 后发表回答