Get number of widgets in sidebar

After some research and based on the answer from Eugene Manuilov I made a function that adds custom classes to widgets in a specific sidebar (‘sidebar-bottom’ in my case) based on the number of widgets set in that sidebar. This will suit perfectly in horizontal sidebars and themes based on twitter bootstrap that need spanX … Read more

Code for Recent Posts Widget

The default Recent Posts Widget code is in includes/default-widgets.php but you should not be hacking Core code. Copy that function to your theme’s functions.php, rename it, and create your own customized widget.

Is there any way to dynamically alter widget titles?

You can use the widget_display_callback (fired, predictably, just prior to displaying a widget 🙂 ). add_filter(‘widget_display_callback’,’wptuts54095_widget_custom_title’,10,3); function wptuts54095_widget_custom_title($instance, $widget, $args){ if ( is_single() ){ //On a single post. $title = get_the_title(); $instance[‘title’] = $instance[‘title’].’ ‘.$title; } return $instance; } The $widget argument is an object of your widget class, and so $widget->id_base will contain the … Read more

How to enqueue script if widget is displayed on page?

You should be able to call wp_enqueue_script() as part of your Widget output. Edit Quick-and-dirty, using the bare-bones Widgets API class example: <?php class wpse48337_Widget extends WP_Widget { public function __construct() { // widget actual processes } public function form( $instance ) { // outputs the options form on admin } public function update( $new_instance, … Read more

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