Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    for the widget itself there isn’t, but you can make a copy of the widget by extending the widget class like this

    
    add_action( 'widgets_init', 'my_widgets_init', 100 );
    function my_widgets_init() {
        class My_Recent_Ads_Widget extends Adverts_Widget_Ads {
            public function widget($args, $instance) {
                // your custom HTML here
                return parent::widget($args, $instance);
            }
        }
        unregister_widget( "Adverts_Widget_Ads" );
        register_widget( "My_Recent_Ads_Widget" );
    }
    

    Now you will just need to modify the content function widget() returns to display your own version of the template.

    Thread Starter Ricky Poon

    (@poonasor)

    Thank you,
    will this create a new widget? or would it be the same as WPAdverts Ads widget?
    i’ve added the code into functions file but I don’t see a new widget registered

    Plugin Author Greg Winiarski

    (@gwin)

    This will just overwrite the original Related Ads widget, by default this code does not do anything, you would need to modify the lines

    
    // your custom HTML here
    return parent::widget($args, $instance);
    

    to see the result in the sidebar in the frontend.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Widget Template’ is closed to new replies.