Using AJAX in WordPress Widget

AJAX/jQuery is not limited to any specific “area” like plugins or widgets, in fact some plugins consist solely of widgets (although afaik the converse cannot be said). This Smashing article might be a good primer. When you finish with that then check out Gary Cao’s WordPress + AJAX tips and come back with a more … Read more

Dynamic Width of Widgets

While this doesn’t answer your specific question, it may provide a solution for you. With a proper CSS selector, you can target a DIV of class “span6” with rules that are separate from a SECTION of class “span6”. In your CSS, write your selectors like this: div.span6 { rules; rules } section.span6 { differentrules; }

Can’t output the number 0 in widget

If you add an exact comparison to the test it should work: $t1Inning1 = isset( $instance[‘t1Inning1’] ) && $instance[‘t1Inning1’] !== ” ? $instance[‘t1Inning1’] : ‘-‘;

Add sidebar in inner pages

This question has been answered many times already on this site. There’s 2 simple steps: One: Add to functions file register_sidebar( array( ‘name’ => __( ‘Your Sidebar’ ), ‘id’ => ‘wpsites-sidebar’, ‘description’ => __( ‘Your Sidebar Description.’ ), ‘before_title’ => ‘<h1>’, ‘after_title’ => ‘</h1>’, ) ); Two: Add where you want to output sidebar <?php … Read more

How to show a widget for logged-in users only?

Your widget is an extension of the WP_Widget class, which defines the widget function. This is where your code should go. class WPDev_156470_Widget extends WP_Widget { // other stuff public function widget( $args, $instance ) { if ( ! is_user_logged_in() ) { echo ”; return; } // logged-in-user stuff } // other stuff } // … Read more

Add space to the end on a widget

In your style.css add this: .widget { margin-bottom: 20px; } That should give all your widgets 20 pixels of spacing but only works when the widgets are stacked on top of eachother. If you have multiple sidebars and only want this to happen on a single sidebar, add a more-specific selector i.e. .my-special-sidebar .widget { … Read more

Paginate recent posts widget

Remove: ‘no_found_rows’ => true, from your WP_Query call inside the widget code. Additionally I would suggest to make this change : ‘base’ => add_query_arg( ‘latest_page’, ‘%#%’ ), in your paginate_links call, because add_query_arg() will handle if ? or & is used. This should make the pagination work in your widget. Note: I’m almost, haven’t tested … Read more

Why is the phone number a hyperlink on desktop sites, in my widget?

I think I see the problem now. None of your links have a closing anchor tag which is cascading down until it hits the end at which point you close it on phone number: Your Code: echo ‘<a href=”‘.$facebook.'” target=”_blank”><img src=”‘. get_stylesheet_directory_uri() .’/images/fb.png” height=”24″ width=”24″ alt=”facebook”>’; What it should probably look like: echo ‘<a href=”‘.$facebook.'” … Read more