Show post tags in a widget

Tags can be shown outside the Post loop using the global functions. Step 1 : Get a PHP Code Widget (this solved many problems) Step 2 : Place the Code <?php the_tags(); ?> in widget and Save. Check Tags Documentation to tweak display order. All done just rock and roll.

Get Widget Instance inside Widget

You can get widget options using following code $current_widget_options = $this->get_settings(); This will return array like array(instance number => settings). Instance number refers to the $number of widget. Example: If your widget instance number is 2 then your required options will be at $current_widget_options[2] Alternative: As get_settings() is deprecated, you can use get_option. Check following … Read more

How Do I Add Custom CSS To Only Certain Widgets

Hi John: I think this is what you are looking for (I’d explain the code be I think it’s self-explanatory; let me know if not): <?php add_filter(‘dynamic_sidebar_params’,’my_dynamic_sidebar_params’); function my_dynamic_sidebar_params($params) { $sidebar_id = $params[0][‘id’]; $sidebar_widgets = wp_get_sidebars_widgets(); $last_widget_id = end($sidebar_widgets[$sidebar_id]); if ($last_widget_id==$params[0][‘widget_id’]) $params[0][‘before_widget’] = str_replace(‘ class=”‘,’ class=”last_widget ‘,$params[0][‘before_widget’]); return $params; }

Adding iframe Content to Sidebar Widget

Just create a widget that doesn’t filter your input. This is probably the most simple widget with user input you can build. Here is the widget I use in my plugin Magic Widgets. /** * Simplified variant of the native text widget class. * * @author Fuxia Scholz * @version 1.0 */ class Unfiltered_Text_Widget extends … Read more

Modifying the default search widget

You can hook into the ‘get_search_form’ action hook ( check out the “last option” part of the link below ). Set the priority high enough to override anything created in a theme. A plugin could look like ( from the link below ): function my_search_form( $form ) { $form = ‘<form role=”search” method=”get” id=”searchform” class=”searchform” … Read more

Get a list of all Widgets registered in WordPress admin widgets-area

Widgets are stored in a public variable $widgets in the class WP_Widget_Factory. You can access this class per global variable $wp_widget_factory. To get all registered widgets, list the keys: add_action( ‘wp_footer’, function() { if ( empty ( $GLOBALS[‘wp_widget_factory’] ) ) return; $widgets = array_keys( $GLOBALS[‘wp_widget_factory’]->widgets ); print ‘<pre>$widgets=” . esc_html( var_export( $widgets, TRUE ) ) … Read more

How to use is_active_widget?

You should make the check inside the widget class, unless you don’t have a choice. The example in the codex is pretty much what you’re looking for: class cbs_map_widget extends WP_Widget{ function cbs_map_widget(){ $this->WP_Widget(‘cbsmaps’, __(‘Widget Name’), array(‘classname’ => ‘cbsmaps’, ‘description’ => __(‘whatever’))); … add_action(‘wp_enqueue_scripts’, array(&$this, ‘js’)); } function js(){ if ( is_active_widget(false, false, $this->id_base, true) … Read more

Extend WordPress 3.8 Site Activity Dashboard Widget to include more comments

Seems like there is no filter for this (yet), but you can unregister the default activity widget and register (within your functions, or even better within your plugin as recommended by Dave Warfel) a similar activity widget with your custom settings: // unregister the default activity widget add_action(‘wp_dashboard_setup’, ‘remove_dashboard_widgets’ ); function remove_dashboard_widgets() { global $wp_meta_boxes; … Read more

dynamically add scripts to WP_Widget widget() method

I’m plucking this code out of my Total Widget Control plugin, so it might throw an error or two. I dunno, just let me know if it does. This is basically the widget code that I use for everything that I build. if (!function_exists(“register_multiwidget”)): /** * Register a widget * * @param $widget */ function … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)