How to create a widgetized sidebar for every category dynamically?

Not a good thing if you have a lot of categories, so be careful! First, add the following function in functions.php: add_action( ‘widgets_init’, ‘generate_widget_areas’ ); function generate_widget_areas() { //Do not create for uncategorized category $terms = get_categories(‘exclude=1&hide_empty=0’); foreach ($terms as $term) { register_sidebar( array( ‘name’ => ‘Category ‘.$term->name, ‘id’ => $term->slug.’-widget-area’, ‘description’ => ‘Widget area … Read more

Add class to before_widget for all widgets with a dropdown and a counter

The CSS classes are applied in the function dynamic_sidebar(). There is no specific filter for that: // Substitute HTML id and class attributes into before_widget $classname_ = ”; foreach ( (array) $wp_registered_widgets[$id][‘classname’] as $cn ) { if ( is_string($cn) ) $classname_ .= ‘_’ . $cn; elseif ( is_object($cn) ) $classname_ .= ‘_’ . get_class($cn); } … Read more

Getting an ordered list of tags – via wp_tag_cloud or not?

one possibility: using the ‘format=array’ and ‘echo=0’ parameters; and building a foreach loop to output each tag: <ol> <?php $wptc = wp_tag_cloud(‘smallest=12&largest=12&orderby=count&order=DESC&format=array&unit=px&number=5&echo=0’); foreach( $wptc as $wpt ) echo “<li>” . $wpt . “</li>\n”; ?> </ol>

How do I hook a sidebar via add_action?

Explanation There’s the global array $wp_filters. This array stores some sub arrays. One for each priority. Each sub array then contains an array for each callback added. And the keys for those sub-sub arrays are the attached functions. Example If you do the following, somewhere in your code (preferable after the init hook): echo ‘<pre>’; … Read more

bloginfo(‘stylesheet_directory’) vs. get_stylesheet_directory_uri() and include(‘file.php’) vs. get_template_part()

get_stylesheet_directory_uri() returns a value, it doesn’t print anything. So you have to use: echo get_stylesheet_directory_uri(); get_template_part() is just a wrapper for locate_template(). But the latter has one advantage: It returns the path of the file it has found. Try the following: $path = locate_template( ‘sidebar-front.php’, TRUE ); echo $path;

Add div class to only one widget

You have two possible solutions. 1. The widget_display_callback filter hook This filter hook parameters allows you to target easily the widget instance and override it’s arguments. A possible approach would be: Inside the filter callback, modify the arguments for that instance, display it and then return false to prevent it from being displayed again the … Read more

Adding ‘current_post_item’ class to current post in the loop

You should be able to get the queried object id and use that for comparison inside your custom loop.. Before your existing loop code(what you have posted above), but obviously after the opening PHP tag.. global $wp_query; $current_id = $wp_query->get_queried_object_id(); Then somewhere inside your custom WP loops.. if( $current_id == get_the_ID() ) { // This … Read more

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