Give a function a unique ID
Just… call the function again – you only need to include it once! include ‘./path/to/lib.php’; echo_tweet_js(); // a little tweeting here … echo_tweet_js(); // and a little tweeting over here!
Just… call the function again – you only need to include it once! include ‘./path/to/lib.php’; echo_tweet_js(); // a little tweeting here … echo_tweet_js(); // and a little tweeting over here!
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
The template field allows you to enter what will appear on the event list widget. It accepts various place holders (you can see the documentation here – the template can be used for the [eo_events] shortcode too). One of the place-holders is %start{date-format}{time-format}% which outputs the start date/time of an event with the specified date … Read more
I did! Write this codes in functions.php add_filter( ‘widget_categories_args’, ‘force_widget_cat_args’ ); function force_widget_cat_args($cat_args) { $cat_args[‘hierarchical’] = 0; return $cat_args; }
I fixed this by adding: global $post; More specific: I can’t explain why this works, that’s beyond my WordPress skills, but I added it right after the start of the query, so the code looks like this: <?php global $post; $loop = new WP_Query( array( ‘post_type’ => ‘kurs’, ‘posts_per_page’ => ‘5’, ‘meta_key’ => ‘dato’, ‘meta_value’ … Read more
I can’t really speak to best practice, since I’m relatively new to WordPress (~1 year). But I am a website developer and I have been hacking around various widgets trying to make them behave the way I want. Here are my top 4 irritations: widgets/plugins that don’t use wp_enqueue_style(). How can I get rid of … Read more
// 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
There’s no need to nest classes (and you can’t anyway), you just create a new instance of the class. The code below would automatically call the My_Widget class to create a widget based on your existing code. Class plugin_name { // Call the widget class public function __construct(){ $this->widget = new My_Widget(); $this->widget->getWidget(); } } … Read more
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
You can list all the attributes of a product by putting the following code in a template file: global $product; $product->list_attributes();