Forums

[resolved] Create two widgets in plugin with WP_Widget (2 posts)

  1. Darrell Schauss
    Member
    Posted 2 years ago #

    I have two different widgets I want to be available when someone installs my plugin. I made one widget with
    class MYWIDGET extends WP_Widget { //everything here }
    then

    function widget_MYWIDGET_init() {register_widget('MYWIDGET');}
    add_action('widgets_init', 'widget_MYWIDGET_init');

    I tried duplicating the whole class then doing another register_widget but it isn't working. Also tried doing another init function and add_action

  2. Darrell Schauss
    Member
    Posted 2 years ago #

    I figured it out. You can simply duplicate the whole process in the same plugin file. I just overlooked not having this part unique between the two.

    $this->WP_Widget('yawQuestions',...

Topic Closed

This topic has been closed to new replies.

About this Topic