Inject “fake” category to widget/block

Done like this: function cat_filter($args) { if (count($args) < 10) { return $args; } $new = new WP_Term((object)[ ‘term_id’ => -17, ‘name’ => ‘Blog’, ‘slug’ => ‘blog’, ‘taxonomy’ => ‘category’, ]); array_splice($args, -5, 0, [$new]); return $args; } add_filter(‘get_terms’, ‘cat_filter’, 10, 1); add_filter(‘term_link’, function( $url, $term, $taxonomy ) { if ( $term->term_id == -17 ) … Read more

Widget constructor: about $id_base and $options

The reason is simply customization (these values end up in widget’s HTML markup). If someone needs to change this stuff (for example to be compatible with some script without adding wrapper layers) the option is there. As for methods calling – parent:: explicitly calls method from parent class, $this-> calls method from current class. Since … Read more

widgets in footer?

Here is complete code that runs this sidebar from sidebar-footer.php template: <?php if ( is_active_sidebar( ‘first-footer-widget-area’ ) ) : ?> <div id=”first” class=”widget-area”> <ul class=”xoxo”> <?php dynamic_sidebar( ‘first-footer-widget-area’ ); ?> </ul> </div><!– #first .widget-area –> <?php endif; ?> You can move this snippet around, but it might break styling. Also Twenty Ten is often upgraded … Read more

recent comments filter by author, page, category

I don’t use widgets for this as you can easily create one and use get_comments( $args ); for the most cases for example: 10 last comments by page is : $args = array( ‘post_id’ => $post_id, ‘number’ => 10, ‘status’ => ‘approve’); $comments = get_comments($args); foreach($comments as $comment) : echo($comment->comment_author . ‘<br />’ . $comment->comment_content); … Read more

Preset Widgets ONLY after site is initially created

Why not output your Theme’s custom Widgets using the_widget(), inside of a if ( ! dynamic_sidebar( ‘sidebar-name’ ) ) conditional? e.g. <?php if ( !dynamic_sidebar( ‘sidebar-right’ ) ) { $widgetsidebarrightargs = array( ‘before_widget’ => ‘<div class=”widget”>’, ‘after_widget’ => ‘</div>’, ‘before_title’ => ‘<div class=”title widgettitle”>’, ‘after_title’ => ‘</div>’ ); the_widget(‘WP_Widget_Calendar’ , ‘title=” , $widgetsidebarrightargs ); the_widget( … Read more

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