• Resolved phoenixobia

    (@phoenixobia)


    Hi, your plugin seems promising but I can’t figure out how to display the output.
    The instructions are not clear. Could you please provide a working example and tell me which parts of the code I need to change based on my custom field name and custom post type?

    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Navneil Naicker

    (@navzme)

    WordPress has messed up the usage area where the code is but let paste it over here.

    <?php
    	//Get the images ids from the post_metadata
    	$images = acf_photo_gallery('gallery_images', $post->ID);
    	//Check if return array has anything in it
    	if( count($images) ):
    		//Cool, we got some data so now let's loop over it
    		foreach($images as $image):
    			$title = $image['title']; //The title
    			$caption= $image['caption']; //The caption
    			$full_image_url= $image['full_image_url']; //Full size image url
    			$full_image_url = acf_photo_gallery_resize_image($full_image_url, 262, 160); //Resized size to 262px width by 160px height image url
    			$thumbnail_image_url= $image['thumbnail_image_url']; //Get the thumbnail size image url 150px by 150px
    			$url= $image['url']; //Goto any link when clicked
    			$target= $image['target']; //Open normal or new tab
    			$alt = get_field('photo_gallery_alt', $id); //Get the alt which is a extra field (See below how to add extra fields)
    			$class = get_field('photo_gallery_class', $id); //Get the class which is a extra field (See below how to add extra fields)
    ?>
    <div class="col-xs-6 col-md-3">
    	<div class="thumbnail">
    		<?php if( !empty($url) ){ ?><a href="<?php echo $url; ?>" <?php echo ($target == 'true' )? 'target="_blank"': ''; ?>><?php } ?>
    			<img src="<?php echo $full_image_url; ?>" alt="<?php echo $title; ?>" title="<?php echo $title; ?>">
    		<?php if( !empty($url) ){ ?></a><?php } ?>
    	</div>
    </div>
    <?php endforeach; endif; ?>
    Thread Starter phoenixobia

    (@phoenixobia)

    Thanks for your response. I added this code to my template and changed:

    $images = acf_photo_gallery(‘image_gallery’, $post->ID);

    to

    $images = acf_photo_gallery(‘my_acf_gallery_slug’, $post->ID);

    But it is not showing anything. Is there something else that I need to change?

    Thanks

    Plugin Author Navneil Naicker

    (@navzme)

    Hi @phoenixobia
    You can do var_dump( $images ); to see if anything is being received by the function. Also make sure the images are uploaded. Check your error logs to see if any conflict errors.

    Let me know

    Thread Starter phoenixobia

    (@phoenixobia)

    Hi. I added <?php var_dump( $images ); ?> in my template and made sure I have images added to the field. On the front end it displays:

    NULL

    Let me know if that helps. I can also give you access to my testing site if you need.

    Thanks

    • This reply was modified 7 years, 11 months ago by phoenixobia.
    Thread Starter phoenixobia

    (@phoenixobia)

    I added the var dump as follows:

    $images = acf_photo_gallery(‘photo_gallery’, $post->ID);
    var_dump( $images );

    It displays:
    array(0) { }

    I made sure I have added the photos and set their captions too.

    Plugin Author Navneil Naicker

    (@navzme)

    Hi @phoenixobia
    There is something else that you can try. Locate this function in your code acf_photo_gallery('gallery_images', $post->ID);. Hard Code the $post->ID something like acf_photo_gallery('gallery_images', 11);//11 is my $post->ID.

    Which theme and plugins are you using, maybe if I can replicate this issue on my test site.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to display exactly?’ is closed to new replies.