Display images attached to current post only
-
Hi, after struggling and googling for last 2-3 days I have failed to find solution to my problem. I want to display my post text and images seperately, like in two different columns. As a newbie to wordpress I was not sure how to do that so I followed dew tricks found online. Unfortunatly, they work but not the way I want them to. Now its displayign all the images present in media instead of the images which I inserted in the current post. I found the following snippet in almost every solution related to this topic. As I am not advance on wordpress I am not sure if I am missing something or it is not going to do my job anyway.
Anyone helping will be really a savior as I need this feature on my curent project which is due to go live very soon.Thanks in advance.
Code:
<?php $args = array( 'post_type' => 'attachment', 'post_status' => 'any', 'post_parent' => $post->ID ); $attachments = get_post($args); if ($attachments) { foreach ( $attachments as $attachment ) { echo '<div class="col-md-4 col-sm-4 col-xs-6">'; the_attachment_link( $attachment->ID , flase ); echo '</div>'; } } wp_reset_postdata(); ?>
- The topic ‘Display images attached to current post only’ is closed to new replies.