page url in shortcode

Depending on how the page’s query and loop are constructed, when you access the post object from the sidebar or footer, you sometimes get the last post in the loop rather than the page itself. You can ensure you’re getting the original (page) object by running wp_reset_query() from inside your widget (before you access the … Read more

Strange widget behavior

I am not seeing you registering the widget in this code. For inside of a theme: register_widget(‘WP_Widget_Mood’); For inside of a plugin: add_action( ‘widgets_init’, create_function(”, ‘return register_widget(“WP_Widget_Mood”);’) );

Single Widget Multi Sidebar

I figured it out after looking at wp_option tables for my widget and the sidebars_widget option I figured out that my widget name has to be none white space separated, in my case it should be anzima_posts_widgets, also I have to include the base-id in the control_ops parameter as the first index. Another issue I … Read more

How do I stop out of stock items from appearing on my WooCommerce site when using the Layered Nav widget [closed]

// Out of stock for general woocommerce – might help someone function product_in_stock($post, $product) { if (!$product->is_in_stock()) { $STOCK = TRUE; return $STOCK; } else { return false; } } function check_if_out_of_stock(){ global $post,$product; $stock = product_in_stock($post,$product); $output=”<div class=””; $output .= $stock?”instock”:”outofstock”; $output .= ‘”>’; echo $output; } add_action( ‘woocommerce_before_shop_loop_item’, ‘check_if_out_of_stock’); function close_out_of_stock(){ echo “</div>”; … Read more

Author Link in Recent Posts Widget

I think the rather simplistic approach would be: copy the whole WP_Widget_Categories from wp-includes/default-widgets.php, and paste it to your functions.php. In there, you could modify the output by customizing this part of the class: class WP_Widget_Recent_Posts extends WP_Widget { … <?php echo $before_widget; ?> <?php if ( $title ) echo $before_title . $title . $after_title; … Read more

Show or hide a widget from pages

Barring the discovery of a plugin that does this already (I’m not aware of any that specifically do what you want) you’ll need to create your own. add_meta_box and add_filter(‘widget_display_callback’, $instance, $widget, $args) should be the bulk of what you need