Home › Forums › General Issues › Get term ACF Image Field › Reply To: Get term ACF Image Field
I tried
<?php $args = array( 'hide_empty=0',
'childless' => 1,
'number' => 6,
'orderby' => 'ID',
'order' => 'ASC'
);
$terms = get_terms( 'molecules_of_the_month', $args );
if ( ! empty( $terms ) ) :
// $termid = get_queried_object()->term_id;
// var_dump($termid);
$summaryimage = get_field('summary_preview_image', 'tax_name_', 'molecules_of_the_month');
// print_r($summaryimage);
$size = 'full'; // (thumbnail, medium, large, full or custom size)
$count = count( $terms );
$i = 0;
$term_list = '<p class="molecule-of-the-month">';
?>
<div id="<?php echo esc_attr($id); ?>" class="<?php echo esc_attr($className); ?>">
<div class="slider mobile-slider splide" data-splide='{ "type" : "loop", "perPage": "3", "arrows": 0, "breakpoints": { "99999": { "destroy": 1 }, "767": { "perPage": "1" } } }'>
<div class="splide__track">
<ul class="post-grid splide__list">
<?php
if($term_list):
foreach ( $terms as $term ) {
$i++;
$term_list .= '<a href="' . esc_url( get_term_link( $term ) ) . '" alt="' . esc_attr( sprintf( __( 'View all post filed under %s', 'theme' ),
$term->name ) ) . '">' . $term->name . '</a><figure class="post-featured-image">' .
wp_get_attachment_image( $summaryimage, $size )
. '</figure>';
if ( $count != $i ) {
$term_list .= ' · ';
}
else {
$term_list .= '</p>';
}
}
echo $term_list;
endif; ?>
</ul>
</div>
</div>
</div>
<?php endif;?>
and the var_dump
for summary_image
is NULL
. Do not get it. And the ACF field is there:
if( function_exists('acf_add_local_field_group') ):
acf_add_local_field_group(array(
'key' => 'group_612651d5d04ad',
'title' => 'Molecule Archive Fields',
'fields' => array(
array(
'key' => 'field_6126521430c38',
'label' => 'Slide Deck',
'name' => 'slide_deck',
'type' => 'file',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'return_format' => 'array',
'library' => 'all',
'min_size' => '',
'max_size' => '',
'mime_types' => '',
),
array(
'key' => 'field_6126525730c39',
'label' => 'Slide Deck Preview Image',
'name' => 'preview_image',
'type' => 'image',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'return_format' => 'id',
'preview_size' => 'medium',
'library' => 'all',
'min_width' => '',
'min_height' => '',
'min_size' => '',
'max_width' => '',
'max_height' => '',
'max_size' => '',
'mime_types' => '',
),
array(
'key' => 'field_6131b9c9bedc9',
'label' => 'Summary',
'name' => 'summary',
'type' => 'file',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'return_format' => 'array',
'library' => 'all',
'min_size' => '',
'max_size' => '',
'mime_types' => '',
),
array(
'key' => 'field_6131b9e1bedca',
'label' => 'Summary Preview Image',
'name' => 'summary_preview_image',
'type' => 'image',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'return_format' => 'id',
'preview_size' => 'medium',
'library' => 'all',
'min_width' => '',
'min_height' => '',
'min_size' => '',
'max_width' => '',
'max_height' => '',
'max_size' => '',
'mime_types' => '',
),
),
'location' => array(
array(
array(
'param' => 'taxonomy',
'operator' => '==',
'value' => 'molecules_of_the_month',
),
),
array(
array(
'param' => 'taxonomy',
'operator' => '==',
'value' => 'molecules_of_the_year',
),
),
),
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
'active' => true,
'description' => '',
));
endif;
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.