Tag Info

Hot answers tagged

2

Keep in mind that the return value of get_the_terms() can be of the type of array|WP_Error Your snippet should check if you get the correct type returned $terms = get_the_terms( 0, 'product_tag' ); if ( ! is_wp_error( $terms ) AND is_array( $terms ) AND ! empty( $terms ) ) { foreach( $terms as $term ) printf( ...


1

Using the_widget() denies those $instance variables being set, which they normally are when you stick it in a Sidebar in the back end. Try something like this: the_widget('bannerWidget', array( 'title' => 'WordPress rocks!', 'text' => 'Hello World.', 'textarea' => 'Some content for the textarea' ) ); the_widget is for hard-coded ...


1

You have one big problem and then I would suggest a few suggestions on your code sidebar-widgets != sidebar-1 You register a sidebar with id sidebar-widgets but you are calling sidebar-1 You don't need to do this if (function_exists('register_sidebar')). register_sidebar is a core function, so it will always exist. It is not wrong, but it wastes space :-) ...


1

I would remove the jQuery save function that was added... and then... Try this for the form function: public function form( $instance ) { // Code for editing/adding title and adding IDs to the <select> object // ... <?php printf ( '<select multiple="multiple" name="%s[]" id="%s" class="widefat" size="15" ...


1

Read: SELECT_a_Column $sql = "SELECT 'liters' FROM " . $wpdb->prefix . "tfp"; $liters = $wpdb->get_col( $sql ); if( $liters ) { foreach( $liters as $liter ) { echo '<option value="' . $liter . '">' . $liter . '</option>'; } }


1

The default text widget - WP_Widget_Text - can be found in wp-includes/default-widgets.php. The input is handled like this: stripslashes( wp_filter_post_kses( addslashes( $text ) ) ); for the text; I assume this should work likewise for your custom widget. Additionally there is: wpautop( $text ) on the output, if the filter is set to do that; But ...



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