How to Catch Last Widget box From Same Widget Area?

Add the following code in your functions.php file of the theme directory. Replace widget name “Home Widget Area” with your widget’s name /*=============WIDGETs CSS CLASS CONTROLLER==============*/ $GLOBALS[‘my_widget_num’]=1; function edei_widget_class_adder($params){ if( $params[0][‘name’]==’Home Widget Area’ ){ $GLOBALS[‘my_widget_num’]++; if( ($GLOBALS[‘my_widget_num’]%4)==0 ){ $params[0][‘before_widget’] = str_replace(‘class=”‘, ‘class=”marginAdjust ‘, $params[0][‘before_widget’]); } } //print_r($params); return $params; } add_filter(‘dynamic_sidebar_params’,’edei_widget_class_adder’); function edei_widget_counter_reset($sidebars_widgets) { $GLOBALS[‘my_widget_num’] … Read more

WP 3.3 RC1 new switch_theme() method foobars sidebars

Likely your code is somehow breaking on the new widget handling methods, which save old widget layouts when theme switches occur. http://wordpress.org/news/2011/11/wherefore-art-thou-widgets/ Most likely, you’ll have to switch themes before adjusting the widgets in it, since widgets don’t survive theme switches anymore, or at least, will be restored from older settings after a theme switch.

Why is registering a sidebar for each page causing my sidebars to reset?

You need to wrap this in a function then add it to the widgets_init action. Also the register sidebar function does not have $arguments for sort_column or sort_order. I would also change the id to ‘sidebar-‘.$page->ID add_action( ‘widgets_init’, ‘prefix_register_sidebars’ ); function prefix_register_sidebars() { foreach($pages as $page){ register_sidebar( array( ‘name’=>$page->post_title, ‘id’=> ‘sidebar-‘.$page->ID, ‘before_widget’ => ‘<div id=”%1$s” … Read more

Upgraded to 3.3, My Widgets Disappeared

Check if your theme is compatible with WP 3.3. To check, you may try switching to the default theme (twentyeleven) for a moment by renaming your current theme’s folder in wp-content/themes. The idea is to force WordPress to fall back to the default theme to rule out any theme-specific issue. -also, make sure all your … Read more

How to customize wordpress sidebar widget

register_sidebar(array( ‘name’ => ‘Post Sidebar’, ‘before_widget’ => ‘<div id=”%1$s” class=”widget %2$s”>’, ‘after_widget’ => ‘</div></div>’, ‘before_title’ => ‘<div class=”titlediv”>’, ‘after_title’ => ‘</div><div class=”widgetdiv”>’, )); You will have a wrapper div, then your title div and then your widgetdiv.

Adding dashboard widgets to show – custom post type stats, information from other plugins

You can get a little more fancy, but this should get you started. add_action( ‘right_now_content_table_end’, ‘wpse_3809’); function wpse_3809() { $types = get_post_types( array( ‘_builtin’ => false ) ); foreach( $types as $type ) : $num_posts = wp_count_posts( $type ); $num = number_format_i18n( $num_posts->publish ); ?> <tr> <td class=”first b b_<?php echo $type; ?>”> <a href=”https://wordpress.stackexchange.com/questions/38098/edit.php?post_type=<?php … Read more

Distinguish between different widgets of the same type

The correct practice is actually to use $args[‘before_widget] and $args[‘after_widget’] to handle the id, class, and anything else. In pseudo code: class My_Widget extends WP_Widget { function My_Widget() { //basic widget settings. $widget_ops = array( ‘classname’ => ‘my-name’, ‘description’ => ‘This is the description’ ); //widget control settings. $control_ops = array( ‘id_base’ => ‘my-name-widget’ ); … Read more

Last Update time in widget

When you save the widget, you can save a field (which won’t be setable in the admin interface) which stores the current time and then use that when you go to do the widget output.

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