Monday, January 16, 2023
HomeWordPress Developmentphp - Easy methods to show taxonomy class Picture from ACF

php – Easy methods to show taxonomy class Picture from ACF


I am new to PHP and attempting to get a picture set utilizing superior customized fields on a web page utilizing a Template. I’ve regarded on the docs and boards however I am unable to get the URL. All of the code works however for the picture. I anticipate the picture URL worth to point out up, however I get a NULL worth as an alternative. I do know I must get the taxonomy ID, I should be lacking one thing.

Right here is a picture of my ACF settings: https://prnt.sc/vwTtPE1UFF2t

And its guidelines: https://prnt.sc/L2wI0evEaYRM

<?
$args = array(
'orderby' => 'id',
'hide_empty'=> 0,
);
$classes = get_categories($args);
$dimension="full";
foreach($classes as $class) {
$picture = get_field('picture', $category->term_id);
var_dump($picture);
echo '
<li>
<a href="' . get_category_link($category->term_id) . '"><img src="'.$picture['url'].'" alt="' . $category->identify . '" /></a>
<span class="crp_title" model="backside:4px;">', (
strlen($title= the_title('', '', false)) > 48 ?
substr($title, 0, 48) :
$category->identify
), '</span>
</li>';
}

echo '</ul>';
echo '<div class="crp_clear"></div></div>';

?>

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments