Categories and products in random order

as suggested by kaiser, my last working edit as solution: ok, inspired by @s_ha_dum answer i manged to get a solution: //this 1. part is out of the woocommerce-template.php and part of the woocommerce_product_subcategories() $product_cat = get_term_by( ‘slug’, $product_cat_slug, ‘product_cat’ ); $product_category_parent = $product_cat->term_id; $pcat_args = array( ‘child_of’ => $product_category_parent, ‘hide_empty’ => 1, ‘hierarchical’ => … Read more

Get a user’s most recent post title

You just set the ‘author’ parameter in a WP_Query query or get_posts (which accepts the same parameters): $recent = get_posts(array( ‘author’=>1, ‘orderby’=>’date’, ‘order’=>’desc’, ‘numberposts’=>1 )); if( $recent ){ $title = get_the_title($recent[0]->ID); }else{ //No published posts } (Note the ‘orderby’ and ‘order’ here are redundant because they are set to their default values, but you get … Read more

Transient not working for custom loops

I have actually worked on a post yesterday (check it out here) and was hit by the same problem. I’m also new to the Transient API, never actually worked with it :-). The problem here is that for a specific loop you need to use a certain value outside of your transient. You are simply … Read more

Query multiple taxonomy in Custom Post Type

There’s the “tax_query” argument available since the latest wp release: global $query_string; $args[‘tax_query’] = array( array( ‘taxonomy’ => ‘status’ ,’terms’ => array( ‘available’, ‘pending’ ) // change to “sold” for 2nd query ,’field’ => ‘slug’ ), ); $args[‘post_type’] = ‘listing’; parse_str( $query_string, $args ); $avail_n_pend = query_posts( $args ); if ( $avail_n_pend->have_posts() ) : while … Read more

Run again current query via ajax but changing a var

You have to note that an ajax request is an entirely new http request, so the $query variable is defined in the page that send the ajax request but will be not set in the page that receive the request. That means that you have completely recreate the query and not change a param. That … Read more

Delete post revisions on post publish

I think a small plugin with the hook ‘publish_posts’ is enough. But I dont know about a core function to delete revisions and I use a query with WP functions. The source is untested, written only for this post. <?php /** * Plugin Name: WPSE71248 Delete Revisions on Publish Posts * Plugin URI: http://wordpress.stackexchange.com/questions/71248/ * … Read more