Using Advanced Custom Fields in a widget
Try passing the post ID as the second parameter: the_field(‘sub_title’, $instance[‘post_id’]);
Try passing the post ID as the second parameter: the_field(‘sub_title’, $instance[‘post_id’]);
It turns out I had overwritten the widget($args) within the widget, hence the before_widget got echoed but not the after_widget. I renamed the widget($args) variable, and all references to it, then the plugins functioned as expected.
You’re using the widget name and not i.d which is why it isn’t working. Change this: if (is_active_sidebar( ‘My_Widgtet_Area’ ) ) : ?> <div id=”widget-sidebar”> <ul> <?php dynamic_sidebar( ‘My_Widgtet_Area’ ); ?> </ul> To this: if (is_active_sidebar( ‘partner-slide’ ) ) : ?> <div id=”widget-sidebar”> <ul> <?php dynamic_sidebar( ‘partner-slide’ ); ?> </ul> The i.d in the template … Read more
In my custom widgets, I had omitted adding the ID to ‘before_widget’ markup, as I wasn’t using the IDs for styling. Turns out this is what the Customizer JS is using to target the widgets. (duh) So, including the proper ID in the widget output makes everything work as it should.
How to enable / use new video / audio / images widgets in WordPress 4.8?
Get widget settings function?
There’s at least 3 options: You could take the code for the native recent posts widget and modify it in your child theme to work with your custom taxonomy. You could create a new WP_Query using the tax parameters. Or you could use a filter widget_posts_args to modify the default output of the native recent … Read more
Sidebars are output in registration order, which is implicitly captured by how they are added to a $wp_registered_sidebars global. This can easily be manipulated, for example following code will move first sidebar to the start: add_action( ‘register_sidebar’, function ( $sidebar ) { global $wp_registered_sidebars; if ( ‘first’ === $sidebar[‘id’] ) { $sidebar = $wp_registered_sidebars[‘first’]; unset( … Read more
The WordPress codex mentions you should call the Widget Class name. Could it be that openingTimesWidget is a function instead of a Class? Following the WP Class naming convention your class would be written like this Opening_Times_Widget. https://codex.wordpress.org/Widgets_API Another possible reason that the widget is not displaying could have to do with the way your … Read more
Uninitialized string offset: 0 This error is showing because there is an empty value. Try checking if the value is !empty() (not empty) first. Here’s the source code you provide in your question with my update. function cf_form_message() { global $errors; if ( is_wp_error( $errors ) && empty( $errors -> errors ) ) { ?> … Read more