For anyone else looking for a solution, this is working for me
if( function_exists(‘acf_add_options_page’) ) {
acf_add_options_page( array(
‘page_title’ => ‘School Options’,
‘position’ => 3
) );
}
For anyone else looking for this I’ve found a solution, probably not the best but it works!
The featured image code higher in the page sets an ‘$image_url’ here:
<?php
$image_id = get_post_thumbnail_id();
$image_url = wp_get_attachment_image_src($image_id,’large’);
$image_url = $image_url[0];
echo ‘‘;
the_post_thumbnail(‘medium’);
echo ‘‘; ?>
Then I just compare the gallery image to that and hide if they are the same
<?php $images = get_field(‘image_gallery’);
if( $images ) { ?>
<div id=”imagegallery”>
<?php foreach( $images as $image ) {
if ($image_url != $image[‘url’]) {
?>
” rel=”shadowbox[gallery]” >” alt=”<?php echo $image[‘alt’]; ?>” class=”alignleft” />
<?php } //End URL Check (to hide featured in gallery)
} // End image loop ?>
</div>
<?php } ?>
UPDATE – Editor has made a bit of a mess of the above, but you get the principal!
Lee
Thanks Marius
That works as a temporary solution, the only downside is if the client reorders the gallery, the featured image may not be the first in the array, ideally the solution would use the id of the featured image and check that?
Lee
Hi, I’ve just tried to code above and it seems to work perfectly
One quick question I show my featured image as a large product image then have the others as thumbnails in a gallery
Is there a way to exclude the featured image from the returned gallery results?
This is the code I’m using to display the gallery
Thanks
Lee
<?php $images = get_field(‘image_gallery’);
if( $images ) { ?>
<div id=”imagegallery”>
<?php foreach( $images as $image ) { ?>
” alt=”<?php echo $image[‘alt’]; ?>” class=”alignleft” />
<?php } ?>
</div>
<?php } ?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.