Add custom element ID depending where the widget place is, sidebar or footer

Solved it by following the advice from @mmm. Using $args[“id”] did the trick. Using $args[“id”] will return the following: post-sidebar footer-first With a little change, my final code is: public function widget( $args, $instance ) { extract($args); // … <div id=’instafeed-<?php echo explode(“-“, $args[“id”])[0] ;?>’ class=”c-widget-instagram”></div> <?php echo $after_widget; } The result is: <div id=’instafeed-post’ … Read more

register widget class not written in theme

include that file in your functions.php file like require_once(‘includes/custom-widgets.php’); then you can call add_action() hook, in your case add_action(‘widgets_init’, ‘SER_register_widgets’); . the idea is to make that function ( ser_register_widgets ) visible in current php file ( functions.php file in this case )

Can I create drag and drop widgets like iGoogle in WordPress?

This is an interesting question. Generally, I agree with EAMann – this would be better suited in a more general discussion. Seeing as you ask it here however, I’m going to give a WordPress specific approach you may want to use. In the context of WordPress, “widget” obviously has a specific meaning. The WordPress sidebar … Read more