Need a function for changing saved post_date or post_date_gmt to relative time in wordpress

Straight from my framework as human_time_diff() involves caching. /** * Time since an entry was posted * * Adapted from binary bonsai * @link http://binarybonsai.com/code/timesince.txt * @license unknown – original source unavailable * * @todo check human_time_diff(); as a replacement * @link http://codex.wordpress.org/Function_Reference/human_time_diff * Note: Rarst said there’s caching involved with this fn. * * … Read more

Using tabs for wordpress plugin

If there is problem only with html markup you should check example from official jQuery UI site here: http://jqueryui.com/tabs/ It looks like yours, but for work you must check if your site include stuff like jquery and jquery ui script, jquery css is important too. After that you should have script with: $( “#tabs” ).tabs(); … Read more

Remove update messages for deactivated plugins

Yep Its possible if you hook a function to site_transient_update_plugins filter hook and check if plugin is activated using is_plugin_active like this: add_filter(‘site_transient_update_plugins’, ‘remove_update_nag_for_deactivated’); function remove_update_nag_for_deactivated($value) { foreach($value->response as $key => $val){ if (!is_plugin_active($val)) unset($value->response[ $key]); } return $value; }

Displaying products from categories in woocommerce

You’re passing bad array keys to $args. Do something like this: $args = array( ‘posts_per_page’ => ’12’, ‘product_cat’ => ‘lead-generation’, ‘post_type’ => ‘product’, ‘orderby’ => ‘title’, ); $query = new WP_Query( $args ); if( $query->have_posts()) : while( $query->have_posts() ) : $query->the_post(); the_post_thumbnail(‘full’); //want to display the thumbnail endwhile; endif; There is no per_page key, use … Read more

How to display variable prices by default in woocommerce?

The function woocommerce_template_single_price() handling the display of the “normal” price is pluggable, which means it can be overridden putting this into your functions.php: //override woocommerce function function woocommerce_template_single_price() { global $product; if ( ! $product->is_type(‘variable’) ) { woocommerce_get_template( ‘single-product/price.php’ ); } } This works because in woocommerce-template.php the functions gets initiated like this: if ( … Read more

How to automatically add and show(open) all the product attributes?

This was not as easy as I initially thought. This will show show every attribute…. apparently by default WC hides any attribute that doesn’t have any terms. They’re already in the code, just with a display:none;. function wpa_120062_scripts(){ ?> <script type=”text/javascript”> jQuery(document).ready(function($) { $(‘.woocommerce_attributes > div’).removeClass(‘closed’).show(); $(‘#woocommerce_attributes a.expand_all’).click(); }); </script> <?php } add_action(‘admin_print_footer_scripts’, ‘wpa_120062_scripts’); Depending … Read more

Restrict individual category combinations

Okay, I’ve had a couple minutes free time, so I wrote up a small plugin. 😉 The following goes into a new plugin file tf-restrict-categories/tf-restrict-categories.php: The introduction <?php /** * Plugin Name: Restrict Categories * Description: Individually restrict category combinations. * License: MIT * License URI: http://opensource.org/licenses/MIT * Text Domain: tf-restrict-categories * Domain Path: /languages … Read more