Forums

[resolved] Tutorial for writing a widget for multisite (6 posts)

  1. b-rad
    Member
    Posted 10 months ago #

    Are there any good tutorials on how to write a simple widget for a WP multisite installation? So far everything I've found has been lacking. I haven't even been able to get sample widget code to show up on the available widgets page.

  2. Andrea_r
    team pirate
    Posted 10 months ago #

    Its the exact same process for writing a widget for a single site. Exactly.

  3. b-rad
    Member
    Posted 10 months ago #

    Hmmm, I wonder why I can't get any examples to show up in my available widgets list. One tutorial said to use:

    class My_Widget extends WP_Widget {
        function My_Widget() {
            // widget actual processes
        }
    
        function form($instance) {
            // outputs the options form on admin
        }
    
        function update($new_instance, $old_instance) {
            // processes widget options to be saved
        }
    
        function widget($args, $instance) {
            // outputs the content of the widget
        }
    
    }
    register_widget('My_Widget');

    and save the php file in my wp-content/plugins folder which I did but it doesn't show up anywhere (yes I know the plugin doesn't do anything but I'm setting my sights low and trying to just get it to show up first).

  4. Andrea_r
    team pirate
    Posted 10 months ago #

    and save the php file in my wp-content/plugins folder which I did but it doesn't show up

    does it show up in the plugins listing and did you activate it?

    Did you include a plugin header in your file?

  5. Ipstenu
    Half-Elf Support Rogue & Mod
    Posted 10 months ago #

    Stupid question - Did you activate the plugin on the site?

  6. b-rad
    Member
    Posted 10 months ago #

    Not a stupid question. Yes and no actually. A few of the tuts I had found neglected to create the proper header which prevented it from showing up anywhere. Once I had a good header in there it showed up under plugins so then I could activate it and head over to the widgets list where it showed up. Thanks!

Reply

You must log in to post.

About this Topic