How to disable Widget Gutenberg Blocks?
How to disable Widget Gutenberg Blocks?
How to disable Widget Gutenberg Blocks?
The problem is that this only works when the widget is present in a sidebar. If you need some code to run independently from widget, I reason it makes sense to add that code separately from widget class. And I also need it to work when I call this widget with the_widget() function, for eg. … Read more
Call wp_get_sidebars_widgets(), and loop through each sidebar. Off the top of my head, text widgets have an ID like widget_text-$i.
I believe @One Trick Pony was right. Shortcode widgets have no ID, so I’ve found a way around. Firstly I used PHP rand function: $var = rand(); And then added the “var” to the ID, so it doesn’t collide with other shortcodes calling the same widget (each one has different random number at the end … Read more
if you take a look at Tabber Tabs Widget plugin does it you will see that it creates a widget and a new “sidebar”, now if you place widgets in that sidebar they will show only where you place the plugins widget. and if you look at what Tabbed Widgets plugin does, it creates a … Read more
Lokks like you have a function declared inside another function, your code is wrong, try this: // wp_dashboard_setup is the action hook add_action(‘wp_dashboard_setup’, ‘mycustom_moviestats’); // add dashboard widget function mycustom_moviestats() { wp_add_dashboard_widget(‘custom_movie_widget’, ‘Movie Stats’,’custom_dashboard_movie_list’); } function custom_dashboard_movie_list(){ $args = array( ‘public’ => true , ‘_builtin’ => false ); $output=”object”; $operator=”and”; echo ‘<table>’; //loop over all … Read more
if you want to show the menus only on child pages then you need to change your conditional statement: global $post; //only on children of 269 if (‘269’ == $post->post_parent){ //menu for Sport & Fitness pages ?> <div id=”seventh” class=”widget-area” role=”complementary”> <?php dynamic_sidebar( ‘sidebar-7’ ); ?> </div><!– #second .widget-area –> <?php //only on children of … Read more
The classes assigned to rendered Widgets are specified by the argument array passed to the register_sidebar() call used to register the sidebar. e.g.: <?php $args = array( ‘name’ => sprintf(__(‘Sidebar %d’), $i ), ‘id’ => ‘sidebar-$i’, ‘description’ => ”, ‘before_widget’ => ‘<li id=”%1$s” class=”widget %2$s”>’, ‘after_widget’ => ‘</li>’, ‘before_title’ => ‘<h2 class=”widgettitle”>’, ‘after_title’ => ‘</h2>’ … Read more
It’s not true that you have to use wp_localize_script before the wp_head. Since 3.3 you can use wp_enqueue_script in the body of the document (i.e. in a widget or shortcode callback) and the script is loaded in the footer. Here’s a skeleton class I’ve used for adding variables for each instance of a widget to … Read more
You don’t need to make it global. If your include a file from within a functions scope, any variables that you defined in that function (before that point) will be exposed in the included file as well. But because the variable you are talking about represents the state of the footer file inclusion (if I … Read more