Home » Topics » General Support » Can't get widget data to show up

Can't get widget data to show up

ACF Widgets Support General Support Can't get widget data to show up

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #104897
    Evan Goldin

    Hey all,

    I must be missing something basic. I have ACF Pro. I created a field group with a custom field called “Price”. Then, I used this plugin you’ve created (because I couldn’t seem to figure out how to create a new widget without code with ACF Pro) to create a new widget called “Price”. I edited a post (technically, a custom taxonomy called “Listings”) in my WordPress and add a value of 1275 to the price field.

    I see the widget showing in my widgets page (http://getcabinfever.com/wp-admin/widgets.php), and I see a blank box appear on the page (http://getcabinfever.com/listing/great-crew-w-hot-tub-11-beds/, bottom right) where it should display the custom field data.

    Yet, nothing shows. It’s just blank. I added a new widget-price.php file to my theme, with just <?php the_field( ‘price’, $acfw ); ?> within that file. Same result.

    Added “Widget is equal to Price” in the ACF Location logic section:

    I’m kind of amazed at how difficult this is. Custom fields are great, and an easy way to add required data to a post. But getting that data to display seems pretty hard. I just want to be able to create new widgets that will display the data I’m adding to my posts.

    Would love some help!
    – Evan

    Daron Spence

    Hey Evan,

    First off, let me thank you for supporting the plugin. I really appreciate it!

    Now, in regards to your question, it seems that there is a misunderstanding going on here.

    ACF Widgets (ACFW) is used to create custom widgets. When you add fields via ACF to the newly created widget, you can fill in that data on /wp-admin/widgets.php, and create as many of those widgets as you want.

    It seems like you are trying to access a custom field from the current post/page from within you widget. This is also possible, but there is no GUI to connect these together. Inside of your widget-price.php file, you need to alter the code to pull the ACF values from the current global $post object.

      global $post;
      the_field('price', $post);

    The above code will echo the price custom field value from the current $post global variable. This variable changes on every page on your website, so be mindful of where the widget/sidebar is being rendered.

    If you’re new to ACF, I recommend doing some tutorials and further familiarizing yourself with it’s provided functions and hooks. While ACF Widgets aims to make some things easier and faster, development is still required in many cases.

    Hope this helps!

    I’m off to bed as it’s waaaay past time here in the US. A friendly reminder so you don’t think I disappeared.


    Evan Goldin


    Thanks for the fast reply! Right before I got this message, I finally managed to figure it out on my own. I removed the $acfw from widgets-price.php, and it started working!

    <div>$<?php the_field('price'); ?></div>

    Question for you — what’s the impact of now having global $post there?

    That prints the price. So … I think I’m all set. Though between this plugin and ACF Pro, I’m still surprised that there’s no way to just do all this with a GUI. Am I missing something basic? Might be more of an ACF Pro question really.

    Thanks for your help. Heading to bed myself, but a reply in the morning would be great if you have a chance.
    – Evan

    Daron Spence

    Not having the global $post; just means that potentially the value passed to the_field function could be incorrect depending on how well your theme and the other plugins you are using were coded.

    As for you but about a GUI, ACF really does cater more towards developers, but if I remember correctly there is another project that tries to give you total GUI control…lemme see if I can find it.

    Ah here it is. Not quite what I was thinking but maybe closer. https://hookturn.io/downloads/acf-theme-code-pro/

    It generates the code you need to insert into your theme. Great for if you can read it but don’t necessarily understand how to write it from scratch yet.

    Glad you got it figured out 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Can't get widget data to show up’ is closed to new replies.