Custom Recent Post Widget

<?php Class My_Recent_Posts_Widget extends WP_Widget_Recent_Posts { function widget($args, $instance) { extract( $args ); $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title'], $instance, $this->id_base); if( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) ) $number = 10; $r = new WP_Query( apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', … Continue reading Custom Recent Post Widget

How to create custom Widget for Custom Post Types

click here OR   class My_Widget extends WP_Widget { public function __construct() { $widget_ops = array('classname' => 'My_Widget', 'description' => 'Displays an My widget!' ); $this->WP_Widget('My_Widget', 'My widget', $widget_ops); } function widget($args, $instance) { // PART 1: Extracting the arguments + getting the values extract($args, EXTR_SKIP); $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']); … Continue reading How to create custom Widget for Custom Post Types