Show widget when not using SSL

WordPress has built-in function for this purpose – is_ssl(). http://codex.wordpress.org/Function_Reference/is_ssl So, you should edit this widget and put something like if ( is_ssl() ) { } else { echo ‘you should use ssl’; }

Displaying a widget only on long posts (over X characters)

Use the function t5_word_count() from this answer and extend the method widget() in your widget class: public function widget( $args, $instance ) { if ( ! is_singular() ) return; $content = get_the_content( ”, TRUE ); $words = t5_word_count( $content ); if ( 50 > $words ) return; // print you widget }

Can I use a form in a dashboard widget?

There are two options to use forms in a dashboard widget: Use the parameter control_callback. See the Codex wp_add_dashboard_widget( ‘my_id’, // $widget_id ‘my_name’, // $widget_name ‘my_render_widget’, // $callback ‘my_control’ // $control_callback ); function my_control() { // print some form elements, WordPress will handle the <form> tag. } If you want to use a form in … Read more

Add before_content and after_content to register_sidebar

The limitation is down to the existing arguments and how pretty much all widgets typically output content: echo $args[‘before_widget’]; if ( $title ) { echo $args[‘before_title’] . $title . $args[‘after_title’]; } // Widget content echo $args[‘after_widget’]; Some widgets may offer before/after content hooks, but if you want a “global” fix there’s no surefire way around … Read more

Radio buttons in widget not saving

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 $this->get_field_id(‘text_area’); … Read more

How to add new sidebar widget area to child theme?

Well, this is what worked for me. In my functions.php file I put the following code: function header_widgets_init() { register_sidebar( array( ‘name’ => ‘Header Sidebar’, ‘id’ => ‘header_sidebar’, ‘before_widget’ => ‘<aside class=”widget %2$s”>’, ‘after_widget’ => ‘</aside>’, ‘before_title’ => ‘<h2 class=”widget-title”>’, ‘after_title’ => ‘</h2>’, ) ); } add_action( ‘widgets_init’, ‘header_widgets_init’ ); …and in my header.php file … Read more

Check if widget is active

According to the Codex, you may add some additional parameters to is_active_widget() to make it work. So try this one: if ( is_active_widget(false, false, ‘Search_Widget_Page’, true) ) { // check if search widget is used // Do not display this widget } else { // Display this widget }

Recent Posts widget without Title

This code will set the title to an empty string if it is set to Recent Posts (Which as you noted, is what the Recent Posts widget will set the title to if it is empty): add_filter( ‘widget_title’, ‘wpse_widget_title’, 10, 3 ); function wpse_widget_title( $title, $instance, $id_base ) { if ( ‘recent-posts’ === $id_base && … Read more

How to change text widget title h2 to h1

The before-title and after-title arguments passed to register_sidebar() need to use underscores: register_sidebar(array( “name” => “Home Consulatation”, “id” => “home_consult”, “before_widget” => “”, “after_widget” => “”, “before_title” => “”, “after_title” => “” )); If you use that the titles won’t have any tags. You need to provide them to the before_title and after_title arguments, like … Read more