Sorting taxonomy columns by meta value numeric

The code I am posting is a modified and simplified version of yours. I got my solution using your code. /** * Filter WP_Term_Query meta query * * @param object $query WP_Term_Query * @return object */ function filter_terms_clauses( $pieces, $taxonomies, $args ) { global $pagenow, $wpdb; if(!is_admin()) { return $pieces; } if( is_admin() && $pagenow … Read more

How to get posts on a specific date – WP Query

<?php // primarily get $year, $month and $day $args = array( ‘date_query’ => array( ‘year’ => $year, ‘month’ => $month, ‘day’ => $day, ) ); $query = new WP_Query( $args ); if ( $query->have_posts() ) { while ( $query->have_posts() ) { // do whatever here } }

how to echo all tables that start with a prefix

You could try changing the output type of get_results() to ARRAY_A or ARRAY_N and see what kind of array they give you. E.g. $tables = $wpdb->get_results(“show tables like ‘pro_hist%'”, ARRAY_A); var_dump($tables); foreach( $tables as $table ) { var_dump($table); } If $table is an array and it has the name as the first value, then get … Read more

Rewrite database urls

Try this plugin: http://wordpress.org/extend/plugins/search-and-replace/ – It helped me dozens of times. Or try this query: UPDATE tablename SET tablefield = replace(tablefield, “findstring”, “replacestring”); Or try this method, dump the database, open the SQL file, do a find and replace in a text editor then reimport it. Take care to backup your database prior to making … Read more

Mysql query LIKE not working

Prepare your Queries! global $wpdb; $wpdb->get_results( $wpdb->prepare( “SELECT %s blog_id, last_updated FROM %s WHERE public=”1″ AND archived = ‘0’ AND mature=”0” AND spam = ‘0’ AND deleted =’0′ AND UPPER(blog_name) LIKE ‘%s’ %s %s “, ARRAY_A ), $extra, $wpdb->blogs, $wpdb->esc_like( ‘A%’ ), $order, $limit ); Never ever send data without prepare! Also: There’re some functions … Read more