Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: Show Category Children
- Plugin URI: http://jakespurlock.com
- Description: Widget that only shows child categories while in the category view.
- Version: 0.5
- Author: Jake Spurlock
- Author URI: http://jakespurlock.com
- */
- ?>
- <?php
- error_reporting(E_ALL);
- add_action("widgets_init", array('Widget_name', 'register'));
- class Widget_name {
- function control(){
- echo 'Used to display only the child categories while browsing category archives';
- }
- function widget($args){
- echo $args['before_widget'];
- $myCat = single_cat_title('', false);
- echo $args['before_title'] . 'More ' . $myCat . $args['after_title']; ?>
- <ul>
- <?php $newmyCat = get_cat_ID( $myCat ); ?>
- <?php wp_list_categories('title_li&child_of=' . $newmyCat); ?>
- </ul>
- <?php echo $args['after_widget'];
- }
- function register(){
- register_sidebar_widget('Child Categories', array('Widget_name', 'widget'));
- register_widget_control('Child Categories', array('Widget_name', 'control'));
- }
- }
- ?>
Add Comment
Please, Sign In to add comment