__( 'Display the latest post from a category', 'text_domain' ), ) // Args ); } public function ak_featured_post() { $widget_ops = array( 'classname'=>'ak-featured-post', // class that will be added to li element in widgeted area ul 'description'=>'Display post from category' // description displayed in admin ); $control_ops = array( 'width'=>200, 'height'=>250, // width of input widget in admin 'id_base'=>'ak-featured-post' // base of id of li element ex. id="example-widget-1" ); $this->WP_Widget('ak_featured_post', 'AK: Featured Post', $widget_ops, $control_ops); // "Example Widget" will be name in control panel } public function form($instance) { if (isset($instance['category'])){ $category = $instance[ 'category' ]; } else { $category = __( 'Featured', 'text_domain' ); } if (isset($instance['title'])){ $title=$instance['title']; } else { $title=__('Featured Post','text_domain'); } if (isset($instance['link_title_to_cat'])){ $link_title_to_cat = $instance['link_title_to_cat']; } else { $link_title_to_cat = __('checked','text_domain'); } if (isset($instance['show_post_title'])){ $show_post_title = $instance['show_post_title']; } else { $show_post_title = __('checked','text_domain'); } if (isset($instance['show_post_limit'])){ $show_post_limit = $instance['show_post_limit']; } else { $show_post_limit = __('1','text_domain'); } if (isset($instance['show_featured_image'])){ $show_featured_image = $instance['show_featured_image']; } else { $show_featured_image = __('checked','text_domain'); } if (isset($instance['show_support_link'])){ $show_support_link = $instance['show_support_link']; } else { $show_support_link = __('checked','text_domain'); } ?>



/>

/>
/>
/>

'.$title.''.$after_title; } else { echo $before_title . $title . $after_title; } $ak_featured_posts_query = new WP_Query( 'cat='.$category.'&showposts='.$show_post_limit ); // get new post data while ( $ak_featured_posts_query->have_posts() ) : $ak_featured_posts_query->the_post(); $image_title = get_the_title(); // The alt text for the featured image ?>
  • 'ak_featured_post_image', 'title' => $image_title)); } } ?>
  • Powered By AK: Featured Post