How do I add Widgets to my theme and activate them on my site?

It sounds like you’re trying to add a new widget area (dynamic sidebar) to your Theme. That process has three parts: Register the dynamic sidebar in functions.php, using register_sidebar(): function wpse121723_register_sidebars() { register_sidebar( array( ‘name’ => ‘Home right sidebar’, ‘id’ => ‘home_right_1’, ‘before_widget’ => ‘<div>’, ‘after_widget’ => ‘</div>’, ‘before_title’ => ‘<h2 class=”rounded”>’, ‘after_title’ => ‘</h2>’, … Read more

Widget options get

Widget data is stored in the options table as a two dimensional array. All data for the same type of widget is stored under the same option key. The key of the outer array is a kind of widget “index”– the identifier for the particular instance of the widget. The inner arrays contain the individual … Read more

How can I add a new CSS class to a widget?

Don’t edit your parent theme’s functions.php file. register_sidebar( array( ‘name’ => __( ‘Sidebar name’, ‘theme_text_domain’ ), ‘id’ => ‘unique-sidebar-id’, ‘description’ => ”, ‘class’ => ‘add class here’, ‘before_widget’ => ‘<li id=”%1$s” class=”widget %2$s”>’, ‘after_widget’ => ‘</li>’, ‘before_title’ => ‘<h2 class=”widgettitle”>’, ‘after_title’ => ‘</h2>’ ) ); Copy it over to your child theme’s functions.php and make … Read more

Unable to save widget contents

Reason is pretty simple and easy to overlook… It has nothing to do with placing both widgets in the same file or anything like this… Let’s look at your code that is responsible for printing the widgets’ form: public function form( $instance ) { echo ‘<p><strong>Sometext here</p>’; } Do you see it now? There are … Read more

How do I pass arguments to dashboard widget callback functions?

The args are stored in the 2nd variable passed to your callback function. add_action( ‘wp_dashboard_setup’, ‘sample_widget_setup’ ); function sample_widget_setup() { wp_add_dashboard_widget( ‘sample_dashboard_widget’, ‘Sample Widget’, ‘sample_dashboard_widget_callback’, null, ‘sample_string’ ); } function sample_dashboard_widget_callback( $var, $args ) { var_dump( $args ); } Output from above: array ‘id’ => string ‘sample_dashboard_widget’ (length=23) ‘title’ => string ‘Sample Widget’ (length=13) ‘callback’ … Read more

How to add a description to Widgets?

Here’s what you looking for: class WP_Widget_Sitemap extends WP_Widget { function WP_Widget_Sitemap() { $widget_ops = array( ‘classname’ => ‘widget_sitemap’, ‘description’ => __( “This is the description” ) ); $this->WP_Widget( ‘sitemap’, __(‘Site Map’), $widget_ops); } function widget() { … } function form() { … } function update() { … } … See: http://codex.wordpress.org/Widgets_API#Developing_Widgets

/images/image.jpg not working in sidebar

PHP code won’t run inside of a text widget. There are plugins that will let you do that, but this type of thing is strongly discouraged. Add this code to your functions.php file, or better yet, make it a simple little plugin: // Enable the use of shortcodes within widgets. add_filter( ‘widget_text’, ‘do_shortcode’ ); // … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)