Tag Info

Hot answers tagged

4

Looking at the source code that WordPress uses to register widgets here, there's a $number parameter defined, in line 242, as: The unique order number of this widget instance compared to other instances of the same class. The function _set($number) stores this ID number attached to the base identifier string of the widget. Then, the function ...


2

In Twenty Fourteen, when you first activate the theme without any changes made to the theme, the widgets that appear there on the sidebar are from the dashboard. You can remove them from Appearance > Widgets and you'll see Search, Recent Posts, Recent Comments etc. in the meta-box "Primary Sidebar". If you want to see the code for the primary sidebar, it's ...


2

Any widgets written to operate as the Core "Recent Posts" widget does can be forced to skip the title by a filter on widget_title: function widget_title_hack_191120($title, $instance) { if (empty($instance['title'])) { $title = ''; } return $title; } add_filter('widget_title','widget_title_hack_191120', 10, 2); I don't know if there is a generic ...


2

I think the easiest way is adding the form via the Shortcode API. The code would look like this: function myform_handler( $atts ){ if (isset(@$_REQUEST['submit'])) { //Do something } else { $return = '<form action="" method="post"> <input type="text" name="myfield"> <input ...


2

The most likely problem is that the theme is outdated and no longer compatible with some core WP functions, the theme was released in 2012 so it's pretty old.


2

You could add this function to your functions.php file. add_filter( 'sidebars_widgets', 'disable_all_widgets' ); function disable_all_widgets( $sidebars_widgets ) { $sidebars_widgets = array( false ); return $sidebars_widgets; } You could also use the Wordpress conditional tags to disable widgets only on certain pages. For example; this would only ...


1

Use the array_filter() function, which will remove every array element that has false as the value. Then you can count the array length. So your example would look like this: $sidebars = array( is_active_sidebar( 'footer-4' ), is_active_sidebar( 'footer-3' ), is_active_sidebar( 'footer-2' ), is_active_sidebar( 'footer-1' ), ...


1

Use the use keyword: $title = $instance['title']; add_action( 'wp_footer', function() use ( $title ) { echo $title; });


1

The form reloads itself each time you save returning to the initial state where all are shown. What you can do is this: // Getting the value of the selected field var my_select_value = $('#widgets-right select.my-select').val(); // If there's no value selected, hide everything. if(my_select_value == 0){ $('.widget-test .row').hide(); } // Otherwise, ...


1

I used Stephen Harris suggested method. $dummy = new My_Widget_Class(); $settings = $dummy->get_settings(); $settings = reset($settings); reset() gives the first key value from array, if you don't know what is the ID of your widget. Note: It does not help if there multiple copies of widget is active. Because it returns the settings of the first copy ...


1

You don’t pass more than argument to that filter, so any callback expecting more than one will not get it. The core calls this filter always like this: $title = apply_filters( 'widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base ); But you are passing just $instance['title']. Add the missing ...


1

Got it, it turns out... The label for each radio button must be the field id / variable, in my example is 'radio_buttons' The IF statement for each radio button must refer to this same ID - $radio_buttons === 'radio_option_1' & $radio_buttons === 'radio_option_2' My new code which works is... <p> <label for="<?php echo ...



Only top voted, non community-wiki answers of a minimum length are eligible