Support

Account

Home Forums General Issues Shortcode not working in Widget

Solving

Shortcode not working in Widget

  • I purchased the developer version of the ACF plugin. I created a Field Group called “Footer Widgets” and then added a text field called “Widget Headline” with shortcode name “widget_headline”. In the location rules I have it setup like this:
    Widget | is equal to | Text

    The field shows below any text widget. I put this text “Our Location” in the field and in the text area I have this:
    <h4>[acf field="widget_headline"]</h4>

    Nothing shows. Thoughts?

  • I also activated my license by going to Custom Fields > Updates and entered my License Key

  • In order to get custom fields for widgets using a shortcode you’d need to specify the correct post id. In this case is would be something like widget_' . $widget_id), so you’d need to include the id in the shortcode.

    See the shortcodes doc here http://www.advancedcustomfields.com/resources/shortcode/ and document on getting values from fields attached to shortcodes here http://www.advancedcustomfields.com/resources/get-values-widget/.

    I don’t know how you’d know what the actual ID of the widget it when editing the widget and this is only a guess. If I save the widget and then inspect the code it has an id that looks something like this widget-14. I suspect, but would have to test, that the ID value of the widget that I’d need to use for ACF is 14

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

The topic ‘Shortcode not working in Widget’ is closed to new replies.