Guest User

Untitled

a guest
Jun 17th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. class Widget_Category extends WP_Widget
  2. {
  3. private $wp_query;
  4. private $test = 'hello world';
  5.  
  6.  
  7. function __construct()
  8. {
  9.  
  10. $arg = array('category_name' => 'songs');
  11. $wp_query = new WP_Query($arg);
  12.  
  13. $widget_options = array('classname' => 'widget-cateogry', 'description' => 'Get specific category');
  14. $widget_controls = array('height' => 300, 'width', 250);
  15.  
  16. parent::__construct('widget_category', 'MY FIRST CATEGORY Widget', $widget_options, $widget_control);
  17. }
  18.  
  19. function widget($arg, $instance)
  20. {
  21. extract($arg, EXTR_SKIP);
  22.  
  23.  
  24. echo $before_widget;
  25. echo $before_title;
  26. echo "Category Widget";
  27. echo test;
  28. echo $after_title;
  29.  
  30.  
  31. while($wp_query->have_posts()):
  32.  
  33. $wp_query->the_post();
  34. ?>
  35. <li> <?php the_title();?> </li>
  36. <?
  37.  
  38. endwhile;
  39.  
  40. //work
  41.  
  42. echo $after_widget;
  43. }
  44.  
  45.  
  46. }
Add Comment
Please, Sign In to add comment