Support

Account

Home Forums Front-end Issues how to display each gallery image in category page

Solved

how to display each gallery image in category page

  • hello guys.

    i want to make categories gallery. so i have one category called gallery, i create some post with gallery images. in gallery category page i want to display each post 4 picture. picture will take from advancedcustomfields gallery field. bellow is my current category-gallery page code, image not coming but title and more link working fine. would guys tell me what how to do ?

    <?php get_header(); ?>
    
    <div class="contentarea">
      <div class="wapper">
        <div class="content clearfix">
          <?php 
    	while ( have_posts() ) :
    	the_post();
    	$images = get_field('gallery_picture');
    
    	?>
          <h2><a href="<?php  the_permalink(); ?>">
            <?php  the_title(); ?>
            </a></h2>
          <a href="<?php echo $image['url']; ?>"> <img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" /> </a> <a href="<?php  the_permalink(); ?>" class="info">Gallery</a> </div>
        <?php  endwhile; ?>
      </div>
    </div>
    </div>
    <?php get_footer(); ?>
  • problem solve. i made it. code bellow

          <?php 
    	while ( have_posts() ) :
    	the_post();
    	?>
          <h2><a href="<?php  the_permalink(); ?>">
            <?php  the_title(); ?>
            </a></h2>
          <?php
    $images = get_field('gallery_picture');
    $max = 5;
    $i = 0;
    
    if( $images ): ?>
          <ul>
            <?php foreach( $images as $image ): $i++; ?>
            <?php if( $i > $max){ break; } ?>
            <li> <img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" /> </li>
            <?php endforeach; ?>
          </ul>
          <?php endif; ?>
          <a href="<?php  the_permalink(); ?>" class="info">Gallery</a> </div>
        <?php  endwhile; ?>
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.