wrapper div for widgets not showing with all widgets

You’re not echoing the wrapping divs. The register_sidebar only defines the div, but doesn’t render it. You need to extract the texts and echo them, like this: public function widget( $args, $instance ) { extract( $args ); $title = apply_filters( ‘widget_title’, $instance[‘title’] ); echo $before_widget; if ( $title ) { echo $before_title . $title . … Read more

How to append custom text to the output of ‘categories widget’?

To append text to the end of the titles in that widget and nothing more i.e. does not matter the URL, you can just use some CSS. <li> <a class=”my-folder-categories”>Category 1</a> </li> a.my-folder-categories-folder:after {content:” folder”; This will effectivly make the text appear as so: category 1 folder Be sure to add that space in the … Read more

WordPress custom widget undefined variable notice

You can you wp_parse_args to merge $instance with a default array. So, you would start you form function not with extract($instance) but with $defaults = array( ‘title’ => ‘Your title’, ‘text’ => ‘…’, ‘image_url’ => ‘…’ ‘textarea’ => ‘…’ ); $instance = wp_parse_args((array) $instance, $defaults);

Ampersand breaking Widget title

SOLUTION: So, it turned out (of course) I myself was causing the problem (…) I am getting the widgets with the ‘the_widget()’ method and sending the instance params along as I go. The params are query-string-style parameters and are of course ‘glued’ together with ampersands. Now , I wasn’t encoding the individual params so the … Read more

add_action not working within widget() of WP_Wdiget

Not really following how the functions relate to each other and where (so what variables are available, how), but you might try something like: add_action(‘before_test_action’, array($this, ‘widget_test_func’)); public function widget_test_func( $instance) { $boolean = (isset($instance[‘boolean’])) ? $instance[‘boolean’] : ”; if ($boolean == ‘on’) { echo ‘within widget test func’; } }

How do I get an array of widgets?

How do I get an array of widgets? You can look into $sidebars_widgets = wp_get_sidebars_widgets(); print_r( $sidebars_widgets ); Here’s an output example: Array ( [orphaned_widgets_1] => Array ( [0] => text-6 ) [wp_inactive_widgets] => Array ( [0] => text-7 [1] => rss-2 ) [sidebar-1] => Array ( [0] => recent-posts-3 [1] => recent-posts-4 [2] => … Read more

Custom widget is not appearing in the admin area

Your code worked for me; The widget appears in the admin area under Appearance > Widgets and the widget does show output on the front end. Your widget() method is missing the output for $args[‘before_widget’]. echo $args[‘before_widget’]; should be added above <section id=”box” class=”box1″>. This would not cause the issue reported, where the widget does … Read more