How to put a variable in a instance in the widget

As far I understood you want to assign the order number like $order_number = order_generator($email) inside the widget class. Yes, you can do it that way unless the order_generator is in another class. If you order_generator function is in another class then first you need to instantiate the class then call the method like $instance_of_your_class->order_generator($email). … Read more

Custom shortcode is not working in text widget

Shortcodes need to return data, not echo it – use output buffering to capture the output of the include and return it: function related_category_sidebar() { ob_start(); include WP_PLUGIN_DIR . ‘/sabai-directory/assets/templates/template_related_category.php’; return ob_get_clean(); } Then you will also need to do as Charles suggested and enable shortcodes for text widgets: add_filter( ‘widget_text’, ‘do_shortcode’, 11 );

Widgets missing after update

I had to restore sidear_widgets in wp_options and any other entries with option_name including ‘widget’ from a database backup to resolve. Something must have go wrong during the update and all widget settings were lost.

Create onClick Event to Re-load a Widget

I think you something like this. HTML Add this in widget <a href=”https://wordpress.stackexchange.com/questions/254474/javascript:void(0)” id=”add_my_fav”>Add To Favourite<span id=”favCount”></span></a> Ajax Add this in template <?php $nonce = wp_create_nonce(‘addToFav’); ?> <script> jQuery(document).read(function(){ jQuery.ajax({ url: ‘http://example.com/wp-admin/admin-ajax.php’, data: {action:”add_to_favourite”, secret:”<?php echo $nonce; ?>”}, method: ‘POST’, success: function(res){ jQuery(‘#favCount’).html(res); } }) }) </script> PHP Add this in functions.php function addToFavourite(){ if(isset($_POST[‘secret’]) … Read more

How to insert custom widget in custom sidebar in theme activation?

but we have to change some little things if we want this when theme is activated.Changs maded done inside function awesome_register_sidebars.Add below code inside in your theme functions.php file: function awesome_register_sidebars() { $sidebars = array ( ‘a’ => ‘sidebar-footer-1’, ‘b’ => ‘sidebar- footer-2′,’c’=>’sidebar-footer-3’ ); foreach ($sidebars as $sidebar) { register_sidebar( array ( ‘name’ => $sidebar, … Read more