Support

Account

Home Forums Front-end Issues ACF in a widget

Helping

ACF in a widget

  • Hi all.

    I’m using ACF to attach a url to a post. From there I am trying to use it in a loop that is within a widget in a drop down in my navigation.

    I have turned on php execution through widget areas.

    The loop I have works perfectly when not executed through a widget, but when I do use a widget the URL does not get added where it’s needed.

    Any ideas on making the custom fields come through into a loop inside of a widget??

    Thanks

  • Hi @sirblogalot
    It is most likely an issue with scope.

    When you use get_field or the_field in the normal page template, they have access to the global $post object and can find the correct $post_id to load data from.

    Within a widget, however, the functions may not be able to find this global $post object. Perhaps you could do some testing in your code to see if this object can be found and if it’s ID is the correct value.

    good luck

    Thanks
    E

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘ACF in a widget’ is closed to new replies.