Yes thats exactly what I’ve done. I had an existing carousel that pulled images that were attached to the post. But once I implemented ACF gallery…my images stopped appearing in some posts, so I have the new script and the old script running together and I just check to see if the gallery field has images stored. I m also running WPML, that’s why i check for language..
<?php
// get the acf var depending on language using WPML
$images = get_field( ( ICL_LANGUAGE_CODE==’fr’ ? ‘gallerie’ : ‘gallery’ ) );
$src_str = ‘get_field’;
$num_imgs = count($images);
// Do we have images in the ACF Gallery ?
if($num_imgs > 0 && is_array($images) ) {
//
} // no images in ACF gallery but we do have images attached to post
else{
$images = get_children( ‘post_type=attachment&post_mime_type=image&output=ARRAY_A&orderby=menu_order&order=ASC&post_parent=’.$post->ID);
$src_str = ‘get_children’;
}
//if we have images enqueue the carousel scripts
if( $images ):
// Galleria Files
wp_enqueue_script(‘galleria’);
wp_enqueue_script(‘galleria-classic-js’);
wp_enqueue_style(‘galleria-classic-css’);
wp_enqueue_script(‘website-single’);
wp_localize_script(
‘website-single’,
‘MyAjax’, array(” => ”,)
);
?>
<!– Display HTML –>
<div id=”galleria”>
<?php foreach( $images as $image ): ?>
guid ); ?>” alt=”<?php echo ( $src_str == ‘get_field’ ? $image[‘alt’] : $image->post_title ); ?>” />
<?php endforeach; ?>
</div>
<?php endif; ?>
Hi Eliot,
Thank you for taking the time to help me with my problem
I tried what you suggested, iremoved the global $post and for both variables, author_badge and author_id
Both returned empty or blank.
I then did a var_dump on them
and for author_id the result was string(0) “”
and for author_badge the result was bool(false)
I use the same code on a static template outside the loop and it works as expected.
Is it because Im in the wp loop of trying to access acf custom user data?
try this in 1 line
<?php
$items = “<div class=\”av-masonry-entry-content entry-content\”>”.the_field(‘artist’);”</div>”;
?>
Looks like you are missing the closing single quote on ‘artist’
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.