Answer the question
In order to leave comments, you need to log in
WordPress. Ajax load more acf for taxonomy. The field type is gallery. How to output shortcode correctly?
There is a new type of material - photo.
This photo has a taxonomy - photo category - photocat
A gallery type field has been created for the taxonomy.
At the moment I'm outputting this:
?php $photo_gallery_images = get_field( 'photo_gallery', $term_id_prefixed ); ?>
<?php if ( $photo_gallery_images ) : ?>
<?php foreach ( $photo_gallery_images as $photo_gallery_image ): ?>
<a href="<?php echo esc_url( $photo_gallery_image['url'] ); ?>">
<img src="<?php echo esc_url( $photo_gallery_image['sizes']['thumbnail'] ); ?>" alt="<?php echo esc_attr( $photo_gallery_image['alt'] ); ?>" />
</a>
<p><?php echo esc_html( $photo_gallery_image['caption'] ); ?></p>
<?php endforeach; ?>
<?php endif; ?>
$category = get_queried_object();
$current_cat_id = $category->term_id;
$current_cat_name = $category->name;
$taxonomy = 'photocat';
$term_list = wp_get_post_terms($post_id, $taxonomy, array('fields' => 'all'));
$taxonomy_prefix = 'photocat';
$taxonomy = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
$parent = get_term_by('id', $taxonomy->parent, get_query_var('taxonomy'));
$term_id_prefixed = $taxonomy_prefix .'_'. $current_cat_id;
$term_id = $term_list[0]->term_id;
<?php $photo_gallery_images = get_field( 'photo_gallery', $term_id_prefixed ); ?>
<?php if ( $photo_gallery_images ) : ?>
<div class="photo_cat_gallery">
<?php foreach ( $photo_gallery_images as $photo_gallery_image ): ?>
<a data-fancybox="photo_gallery" href="<?php echo esc_url( $photo_gallery_image['url'] ); ?>">
<img src="<?php echo esc_url( $photo_gallery_image['sizes']['thumbnail'] ); ?>" alt="<?php echo esc_attr( $photo_gallery_image['alt'] ); ?>" />
</a>
<?php endforeach; ?>
</div>
<?php endif; ?>
[ajax_load_more preloaded="true" preloaded_amount="4" posts_per_page="4" seo="true" acf="true" acf_field_type="gallery" acf_field_name="alm_gallery" seo="true" container_type="div" images_loaded="true"]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question