Niche issue with ACF FontAwesome plugin - need to emulate {term_id} in PHP

This plugin:

Allows me to have an icon picker for my categories.
I have a TERMS query loop - which gets all parent categories. I want to list them with the icon and term name.
I can get the term with bricks fields. I can get a custom category desc with ACF field - but Bricks doesn’t list the icon field - it just ignores it.
I want to work-around this with custom code - because - get_field(‘category_icon’, ‘category_22’); gets the icon fine.
But I have no idea how to get the ID of the category within the loop. get_queried_object_id() returns null. {term_id} works fine - but I can’t use it in code.
So - how do I emulate {term_id} - in a php block within the loop?
Many thanks

Try $term_id = \Bricks\Query::get_loop_object_id();.

1 Like

This made me so happy I peed a little :smiley: - thank you

1 Like

I imagine you solved this… but for anyone else landing here:
I used the icons for category icons, but later for menu icons (ACF->location=menu item).

The problem is that ACF Fontawesome plugin registers using a legacy method and so doesn’t show for Bricks.

Set the field to return ICON CLASS, and put this in a code block in the loop:

<?php
$term_id = \Bricks\Query::get_loop_object_id(); //as above, gets id of current loop item
$iconFetch = "term_" . $term_id; //build the ACF query- not needed if icon attached to post
$term_icon = get_field( 'mmenu_icon', $iconFetch ); //mmenu_icon is field name
echo '<p><i class="fa bricks-color-secondary ' . $term_icon . '"></i></p>';
?>
1 Like