Post X of Y in single.php / sidebar.php

class MY_Post_Numbers { private $count = 0; private $posts = array(); public function display_count() { $this->init(); // prevent unnecessary queries $id = get_the_ID(); echo sprintf( ‘<div class=”post-counter”>Post number<span class=”num”>%s</span><span class=”slash”>/</span><span class=”total”>%s</span></div>’, $this->posts[$id], $this->count ); } private function init() { if ( $this->count ) return; global $wpdb; $posts = $wpdb->get_col( “SELECT ID FROM $wpdb->posts WHERE post_status=”publish” … Read more

Manual display of widget

I like the answer you found, but I thought I’d tack on another. You could create another sidebar area that’s only displayed on the front page, and then use the “Duplicate Widget” plugin to maintain two instances of a single plugin. It has slightly higher overhead, but becomes much easier to maintain for someone who … Read more

Category specific months list in sidebar.php

you can use getarchives_where filter to get archives by category add_filter( ‘getarchives_where’, ‘my_archives_filter_function’, 10, 2 ); // your filter function replace YOUR CATEGORY ID with category term id e.g(3) function my_archives_filter_function($where) { global $wpdb; $where .” AND $wpdb->posts.ID IN (SELECT $wpdb->posts.ID FROM $wpdb->posts INNER JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) INNER JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id … Read more

List children of second level sub page

Is this what you are after? <?php if($post->post_parent) { // if $post has parent than it is “Second level” and show its children. $children = wp_list_pages(“child_of=”.$post->post_parent.”&echo=0″); } else { // else it’s a “Top level” so display children & grand children? $children = wp_list_pages(“child_of=”.$post->ID.”&echo=0″); } if ($children) { echo “<ul>$children</ul>”; } Source: http://codex.wordpress.org/Function_Reference/wp_list_pages#List_subpages_even_if_on_a_subpage

Ban certain widgets from certain sidebars

You are overthinking it. The concept of widgets is designed to be transferable between widget area (AKA sidebars). If a widget is not tranferable it is just not a true wordpress widget. Now creating your own framework of widgets sound like a non pleasant idea. In addition to fighting the wordpress core code, you will … Read more

Problems with the sidebar args and wp_list_bookmarks

After a few var_dumps I know this: 1) When wp_list_bookmarks is called whithin WP_Widget_Links->widget The ‘class’ parameter is ignored because the ‘category_before’ parameter doesn’t have the %class wildcard. Instead ‘category_before’ will look as if ‘class’ where ‘widget_links’. This is how the function dynamic_sidebar set the $before_widget parameters for the widget once it gets called. Of … Read more

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