April 7, 2017 at 1:13 PM #103224
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 $acfwbut this also does nothing.
Can what I want to do be done?April 7, 2017 at 1:37 PM #103225
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?April 7, 2017 at 3:07 PM #103226
Daron SpenceKeymasterThis reply has been marked as private.April 7, 2017 at 3:13 PM #103228
Thanks for the reply.
This all makes sense. I actually found the
widget_" . $widget_idby 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 hahaApril 7, 2017 at 3:28 PM #103229
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.
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
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 🙂
You must be logged in to reply to this topic.