Home » Topics » General Support » Simply not working

Simply not working

ACF Widgets Support General Support Simply not working

This topic contains 4 replies, has 2 voices, and was last updated by  Daron Spence 1 year, 1 month ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #103224

    Brandon Travis
    Priority Support

    First — I just bought a lifetime license and should have Priority support. As of right now, I am not able to create a new topic in the Priority Support forum.

    Second, can I use this WITHOUT using your widget templates? I have an existing set of custom fields defined that work fine in other places. Inside normal WP_Widget markup, I am trying to get a field that has a value related to it in the DB.

    inside the widget() code, I put $repeater = get_field( 'resource_selector', $acfw );

    This does nothing. When I try to echo the $acfw variable or print out the values, it is completely empty. I’ve tried global $acfw but this also does nothing.

    Can what I want to do be done?


    Brandon Travis
    Priority Support

    I solved this by adding $acfw = 'widget_' . $args[ 'widget_id' ]; inside of my widget() code, but this seems clunky. Is this how its designed to work?


    Daron Spence
    This reply has been marked as private.

    Brandon Travis
    Priority Support

    Thanks for the reply.

    This all makes sense. I actually found the widget_" . $widget_id by reading through your source code actually, haha. Once I saw how it was created, I had a pretty good handle on it.

    Your explanation of how the ACFW plug-in is supposed to work makes complete sense, especially after reading through your code. And you’re right, I am simply using this as a time-saver. I have one specific instance where I need to use custom fields in a widget, and this plugin seemed like an easy way to do it. I’ll play around with using widget templates. If it saves me time in constructing the backend, then its something that I’ll continue to use frequently. No need for a refund, as I got everything working .. albeit kind of hacky haha


    Daron Spence

    Awesome to hear Brandon!

    If you are coding widgets, I recommend taking a look at creating your widgets via the ACFW provided filter vs using the wp-admin interface. That way you can keep your widget code in the theme (rather than in the DB) and then the only file you need to create would be the template.

    https://acfwidgets.com/documentation/hooks/ (acfw_include_widgets) Note to self: add anchors to this page.

    If you don’t use the ACFW version of creating widgets (either through the above filter or via the admin interface) you’ll need to include $args['after_widget'] (or before_title/after_title) somewhere in your WP_Widget::widget() method and then specify that location on the Widgets admin screen for where to render the template.

    Either way, I’m glad you got it figured out and my offer still stands if you want to chat about a specific use case or how you can refactor your current project.

    Enjoy the rest of your day Brandon and thanks for supporting ACF Widgets 🙂

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

The topic ‘Simply not working’ is closed to new replies.