whyisjake

Jake Spurlock

May 14th, 2010
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.02 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: Show Category Children
  4. Plugin URI: http://jakespurlock.com
  5. Description: Widget that only shows child categories while in the category view.
  6. Version: 0.5
  7. Author: Jake Spurlock
  8. Author URI: http://jakespurlock.com
  9. */
  10. ?>
  11.  
  12. <?php
  13. error_reporting(E_ALL);
  14. add_action("widgets_init", array('Widget_name', 'register'));
  15. class Widget_name {
  16.   function control(){
  17.     echo 'Used to display only the child categories while browsing category archives';
  18.   }
  19.   function widget($args){
  20.     echo $args['before_widget'];
  21.     $myCat = single_cat_title('', false);
  22.     echo $args['before_title'] . 'More ' . $myCat . $args['after_title']; ?>
  23.    
  24.     <ul>
  25.         <?php $newmyCat = get_cat_ID( $myCat ); ?>
  26.         <?php wp_list_categories('title_li&child_of=' . $newmyCat); ?>
  27.     </ul>
  28.  
  29.    <?php echo $args['after_widget'];
  30.   }
  31.   function register(){
  32.     register_sidebar_widget('Child Categories', array('Widget_name', 'widget'));
  33.     register_widget_control('Child Categories', array('Widget_name', 'control'));
  34.   }
  35. }
  36.  
  37. ?>
Add Comment
Please, Sign In to add comment