• Hi, trying to find th ebest/easiest way to return FA icon for my requirements. Alongside my icon field I have a field for icon colour so I need to be able to add the_sub_field(‘icon_colour’) inside the <i>

    When I was on v4 I used the class but this wont work for me on v5 because I notice class only returns the class for the icon and not the set (fas, fab etc.)

    I have tried element but this wont allow me to insert my colour field. I could use jQuery as a very last resort but would prefer not to.

    I don’t think Unicode is any benefit to me in this case.

    And when I switch to object, WP tells me:
    Your PHP code changes were rolled back due to an error on line 794 of file wp-content/plugins/advanced-custom-fields-pro/includes/api/api-template.php. Please fix and try saving again.
    Object of class stdClass could not be converted to string

    Any advice appreciated.
    Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Matt Keys

    (@mattkeys)

    Hello @adejones,

    It is curious that you aren’t seeing the prefix when you return just the class. You should be seeing prefix + classname with that setting. If you’ve recently upgraded from FontAwesome 4.x to 5.x, I wonder if you need to resave/reselect those fields.

    As for the object, that error about a stdClass trying to be converted to a string makes it sound like maybe you have some ACF filter/action hook registered in your theme functions or a plugin that is trying to do something with this value, and treating it as a string. Here is an example of what the object contains for the “Align Center” fa field:

    stdClass Object
    (
        [element] => <i class="fad fa-align-center" aria-hidden="true"></i>
        [class] => fad fa-align-center
        [hex] => \f037
        [unicode] => 
        [prefix] => fad
    )
    

    You can also see a preview from this of what you would get if you returned just the element, or the class, or the unicode.

    I hope this helps.

    Matt Keys

    Thread Starter adejones

    (@adejones)

    Thanks for the reply, i’ll have another go with the class, I must have been missing something before.

    Also any plans to update to V6 when it comes out? I am debating pre-ordering a pro license but only have until end of tonight to get $20 off and if your plugin will support v6 then thats sold it for me.

    Plugin Author Matt Keys

    (@mattkeys)

    I haven’t had time to mess with the v6 stuff yet, but if at all possible I am sure I will support it. Hopefully they keep things similar to the v5 releases that I already have infrastructure for supporting in this plugin.

    These releases keep getting more expensive, I may look for some sponsorship to see if the community here will help pay for these licenses for me.

    Right now I am pretty slammed with work so hopefully v6 comes out when things are a bit less hectic for me :).

    Matt Keys

    Thread Starter adejones

    (@adejones)

    Thanks Matt – I think i’ll stick with v5 for a bit then and of course when the time comes i’d be happy to chuck a donation in towards your licensing.

    Thread Starter adejones

    (@adejones)

    Hi Matt

    Almost there with what I need to do but just 2 more questions if I may. I have created a custom icon set but need this set on 160+ websites so can I just use the following via phpmyadmin:
    INSERT into sweb_options (option_id,option_name,option_value) VALUES (‘169141’,’ACFFA_custom_icon_list_v5_SurgeryWeb’,’SERIALISED ICON DATA HERE’);

    And secondly, any way of removing the sections in the select field so that brands, solids etc are just one list and not split up?

    Thanks

    Plugin Author Matt Keys

    (@mattkeys)

    You may need to play around with that SQL query a bit, but I don’t see why something like that wouldn’t work. Obviously do some testing first before you go deploying it to 160+ sites :). I’d be careful about trying to set the option_id directly as this is autoincremented in the options table. It may be advisable to use the update_option() function instead if you can.

    There is a second option called “ACFFA_custom_icon_sets_list” that is a list of the custom fields sets available, which you would also need to create/update in a similar way to whatever you get working for the other option value above.

    As for removing the optgroups in the select fields, I’m not sure there is an easy way to do that for you. Perhaps if that is your goal, you could play around with the “ACFFA_get_icons” filter and return you own list of icons. That may be another way to accomplish your earlier goal as well.

    I don’t have any specific code to share with you on that front, but hopefully that gives you some ideas to play with. As always if you come up with something that works well for you, please do share here for others to see.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Return format’ is closed to new replies.