How to delete a transient on post/page publish?

I am considering it for publication of a new post. Add the below code in your active theme’s functions.php file. function wpse_delete_query_transient( $post ) { // Deletes the transient when a new post is published delete_transient( ‘d_results’ ); } add_action( ‘new_to_publish’, ‘wpse_delete_query_transient’ ); This will delete the transient every time a new post is published. … Read more

Query by one meta_key and sort by another (possibly NULL value)

I don’t think there’s a way to do it without using filters. Using posts_clauses you could do: function wpse163696_posts_clauses( $pieces, $query ) { if ( $query->get( ‘orderby’ ) != ‘dealer_date’ ) { return $pieces; } global $wpdb; $order = $query->get( ‘order’ ); $pieces[ ‘join’ ] .= $wpdb->prepare( ‘ LEFT JOIN ‘ . $wpdb->postmeta . ‘ … Read more

wp_dropdown_categories with multiple select

wp_dropdown_categories has a filter applied to the output that is called right before the function returns or echos the output. With this you can add a filter to your funtions.php file that manipulates the select field and adds a multiple attribute to it. The filter below would search for the select opening tag and add … Read more

Compare two numeric custom fields

I think something like this, but not tested, and my SQL-foo is rather weak: $test = $wpdb->get_col( $wpdb->prepare( ” SELECT DISTINCT $wpdb->posts.* FROM $wpdb->posts INNER JOIN $wpdb->postmeta AS mt1 ON ( wp_posts.ID = $wpdb->postmeta.post_id ) WHERE $wpdb->postmeta.meta_key = ‘goals-made’ AND( mt1.meta_key = ‘goals-against’ AND CAST($wpdb->postmeta.meta_value AS INT) > CAST(mt1.meta_value AS INT) ) ” )); This … Read more

Remove [gallery] shortcode altogether

The short code is actually entered into then page or post content so disabling the short code processing prevents the gallery short code from being replaced with the gallery images but it doesn’t affect the post content. The best solution is to add a new short code handler after removing the default gallery handles. Another … Read more

techhipbettruvabetnorabahisbahis forumutaraftarium24eduseduedusedusedueduedueduseduedu