First of all I have a few weeks of coding in php and wordpress, however while developing the content.php I wanted a specific category of my webpage to behave differently, so this is what I did:
<?php
if( in_category('5') ): /*Special template for Projects category*/ ?>
<div class ="ficsa-grid-container ficsa-frontpage-portfolio-container">
<div class ="ficsa-portfolio-text">
<?php the_title( '<h1 class="entry-title">', '</h1>'); ?><br>
<?php the_content(); ?>
</div>
<?php
$images = get_children( array (
'post_parent' => array(get_the_ID()),
'post_type' => 'attachment',
'post_mime_type' => array('image/jpeg', 'image/gif', 'image/png')
));
if($images) { ?>
<div class="ficsa-portfolio-image">
<div class="swiper-container gallery-top">
<div class="swiper-wrapper">
<?php foreach($images as $attachment_id => $attachment) { ?>
<div class="swiper-slide background-image" href="<?php the_permalink(); ?>" style="background-image: url(<?php echo wp_get_attachment_image_url($attachment_id, 'thumbnail'); ?>);">
</div>
<?php } ?>
</div>
</div>
<div class="swiper-container gallery-thumbs">
<div class="swiper-wrapper">
<?php foreach($images as $attachment_id => $attachment) { ?>
<a class="swiper-slide background-image" href="<?php the_permalink(); ?>" style="background-image: url(<?php echo wp_get_attachment_image_url($attachment_id, 'thumbnail'); ?>);">
</a>
<?php } ?>
</div>
</div>
</div>
<?php } ?>
</div>
<br><br><br>
But I have some problems over here first of all I cannot get the post Images as it gets me all the available images on the media library instead of the one's present in the gallery of the post. I believe this is related with the 'post_parent' , however if I use 'post_parent' => $post->ID it gets me nowhere I've tried as well the get_the_ID() and still nothing.
So what I am wondering is if I am creating or adding my images wrongly on the post or if I am looking at this in a completely wrong perspective. As I would assume that it is possible to get all the images url in a specific post.
I would like to breakdown my post so that the creation of posts would be easy, just add some text, add some images and the template would automatically organize and use the div's properly.
However I've been spending too much time in this issue and I cannot really figure out what I am doing wrong.
Thanks a lot! Hope someone can help :)