Display specific widgets in different area’s around the page

You will want to create a new widget area or dynamic sidebar in your theme’s code. Justin Tadlock has a great tutorial about how to do this, but the basics boil down to this. Add the widget area declaration in your theme’s functions.php file: <?php add_action(‘widgets_init’, ‘my_register_sidebars’); function my_register_sidebars() { /* Register the ‘cartwidgets’ sidebar. … Read more

Custom Widget outputs the input but doesn’t save anything inside the textarea

Your primary issue isn’t with saving the data but displaying in the form if it has been saved. I rewrote the offending function: function form($instance) { $title = strip_tags( $instance[‘title’] ); $info = esc_textarea( $instance[‘info’] ); // var_dump($instance); // debug ?> <p> <label for=”<?php echo $this->get_field_id(‘title’); ?>”><?php _e(‘Title:’); ?></label> <input class=”widefat” id=”<?php echo $this->get_field_id(‘title’); ?>” … Read more

Hide widget to non-logged in users without plugin (functions.php) [closed]

Tested on Twenty Fourteen and works. Change the loop_start hook to another position if needed. The code goes at the end of your child themes functions.php file. function wpsites_register_widget() { register_sidebar( array( ‘name’ => ‘Logged In Only Widget’, ‘id’ => ‘members-widget’, ‘before_widget’ => ‘<div>’, ‘after_widget’ => ‘</div>’, ) ); } add_action( ‘widgets_init’, ‘wpsites_register_widget’ ); add_action( … Read more

How can I add an incremental class identifier to my sidebar widgets?

There doesn’t seem to be an easy way to do this. However, you can try this rather hackish approach: add_filter(‘dynamic_sidebar_params’, ‘my_sidebar_params_cb’); function my_sidebar_params_cb($params) { global $my_widget_counter; if (empty($my_widget_counter)) $my_widget_counter = 1; else $my_widget_counter++; $params[0][‘before_widget’] = str_replace(‘class=”‘, ‘class=”widget_nr_’.$my_widget_counter.’ ‘, $params[0][‘before_widget’]); return $params; }