wordpress - register a widget in function.php


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. add_action("widgets_init", array('Widget_name', 'register'));
  2. class Widget_name {
  3. function control(){
  4. echo 'I am a control panel';
  5. }
  6. function widget($args){
  7. echo $args['before_widget'];
  8. echo $args['before_title'] . 'Your widget title' . $args['after_title'];
  9. echo 'I am your widget';
  10. echo $args['after_widget'];
  11. }
  12. function register(){
  13. register_sidebar_widget('Widget name', array('Widget_name', 'widget'));
  14. register_widget_control('Widget name', array('Widget_name', 'control'));
  15. }
  16. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.