How to add/save/retrieve additional fields to all available widgets?
How to add/save/retrieve additional fields to all available widgets?
How to add/save/retrieve additional fields to all available widgets?
That is not native behavior of it. If you check the source of WP_Widget_Categories $title = apply_filters( ‘widget_title’, empty( $instance[‘title’] ) ? __( ‘Categories’ ) : $instance[‘title’], $instance, $this->id_base ); The title comes exclusively from the value saved in instance (or default if not). There is no logic to tie it in with current context. … Read more
That’s a bug of WordPress core: #32094 Will be fixed in 4.2.3 version of WordPress and patch is available here: 32094.patch
I ended up solving this (in a limited fashion) by just using text, which I linked to the function I wanted using javascript on click. This may not work for others still trying to do what my original intention had been, but maybe this will solve your problem too
Your widget must have a method that looks something like this: public function widget( $args, $instance ) { echo $args[‘before_widget’]; if ( ! empty( $instance[‘title’] ) ) { echo $args[‘before_title’] . apply_filters( ‘widget_title’, $instance[‘title’] ). $args[‘after_title’]; } wp_list_categories(); echo $args[‘after_widget’]; } Apply your filter inside that method, then remove it: public function widget( $args, $instance … Read more
If I am reading this right, all you need is a count of the active sidebars, so: $col = 0; if(is_active_sidebar(‘footer’)) { $col++; } if(is_active_sidebar(‘footer-2’)) { $col++; } if( is_active_sidebar(‘footer-3’)) { $col++; }?> <div class=”<?php echo ‘column-‘.$col; ?>”> Note: I flipped the “column” class so that it begins with a letter. Numbers are not allowed … Read more
i was using get_sidebar() instead of dynamic_sidebar(‘name’)….
This is memory and I can’t test right now, but I believe the title is always set. Use !empty( $settings[‘title’] ) instead and I think you will get the results you expect.
You need an update method which saves your widget settings: function update( $new_instance, $instance ) { for ( $i=0; $i < 3; $i++ ) $instance[ “link_target_$i” ] = $new_instance[ “link_target_$i” ]; return $instance; }
I am not exactly sure what you’re question is but I think you are looking for something like this, mostly cribbed from the Codex: if ( is_active_sidebar( ‘sidebar-1’ ) ) { ?> <ul id=”primary”><?php dynamic_sidebar( ‘sidebar-1’ ); ?> </ul><?php } If the sidebar is not in use, no markup will display. You could add an … Read more