How WP decide to show or not to show in admin panel the pop-up window with hint? Need a fix

Dismissed pointers are stored as user meta, you can inspect this for yourself with: $meta = get_user_meta( wp_get_current_user() ); print_r( $meta[‘dismissed_wp_pointers’] ); In your case, the meta might be empty or damaged, to update dismissed pointers for ALL users on your blog, you could run this function (only once): function wpse80084_dismiss_wp_pointers() { $dismissed = array( … Read more

finding out the top 5 source ( source is a custom taxonomy ), in a given category

Thanks to some leads from the wp-hackers list on this very question and some googling around, here is the answer to my problem $sql = “SELECT count(*) as count,terms2.name as tag FROM wp_posts as p1 LEFT JOIN wp_term_relationships as r1 ON p1.ID = r1.object_ID LEFT JOIN wp_term_taxonomy as t1 ON r1.term_taxonomy_id = t1.term_taxonomy_id LEFT JOIN … Read more

How to back-up a database on IIS

I was able to find the name of the database in word-press’s wp-config.php file under the and was able to create a back-up of the file using MSQL workbench and the tutorial found here http://community.discountasp.net/showthread.php?t=11972.

How to optimize ‘select found_rows()’ query? Several ‘high load average’ alerts daily

This should not break pagination: add_filter(‘pre_get_posts’, ‘optimized_get_posts’, 100); function optimized_get_posts() { global $wp_query, $wpdb; $wp_query->query_vars[‘no_found_rows’] = 1; $wp_query->found_posts = $wpdb->get_var( “SELECT COUNT(*) FROM wp_posts WHERE 1=1 AND wp_posts.post_type=”post” AND (wp_posts.post_status=”publish” OR wp_posts.post_status=”private”)” ); $wp_query->found_posts = apply_filters_ref_array( ‘found_posts’, array( $wp_query->found_posts, &$wp_query ) ); if($wp_query->query_vars[‘posts_per_page’] <= 0) { $wp_query->max_num_pages = 0; } else { $wp_query->max_num_pages = ceil($wp_query->found_posts … Read more

Filtering problem

… I will need to be more specific, by adding a “%” after $author (James). The problem is that this will not work at all. Any idea why? The % is a wildcard with a MySQL LIKE query, which I suspect you know. With meta queries, WordPress will add one to the beginning and one … Read more

Mysql query and odd results

You have to enclose the OR part to brackets: $sql = “SELECT ID,post_title,post_content,post_date,post_type FROM {$wpdb->posts} WHERE (post_content LIKE {$stuff}) AND post_status=”publish” AND post_type=”{$post_type}” AND ID != {$post->ID} LIMIT {$limit}”; $results= $wpdb->get_results($sql); Try this one: SELECT ID,post_title,post_content,post_date,post_type FROM wp_posts WHERE (post_content LIKE ‘%Battery%’ OR post_content LIKE ‘%Watcher%’ OR post_content LIKE ‘%Widget%’ OR post_content LIKE ‘%matches%’ OR … Read more

Running WordPress from MySQL Cluster with HAPRoxy

SELinux was contributing to the problem. The main issue was that an HTML page was attempting to talk to another port on the localhost. I would not have seen the problem if the HAProxy was running on a separate host. The log was revealed in /var/log/messages, where I should have checked but did not considering … Read more

Problem with a query in custom posts

Like the commentor say, couldn’t you use WP_Query for this? $results = new WP_Query(array( ‘post_type’ => ‘products’, ‘meta_query’ => array( ‘key’ => ‘availability’, ‘value’ => $MyDate_a, ‘compare’ => ‘=’ ), ‘order’ => ‘DESC’, ‘orderby’ => ‘meta_value’ ));

Convert many posts from having a specific meta_key to use a post_format

After much reading, i realized that it would be more easily done using the WordPress API, so i baked out this little script. Simply add it to your theme’s functions.php then run it once. When done, remove it. function convertGalleries($test){ $galleries = get_posts(array( ‘meta_key’ => ‘custom_post_template’, ‘post_status’ => array( ‘any’ ),’posts_per_page’=>-1 )); if($test){ return count($galleries); … Read more

Woocommerce: Grab total revenue of a product over all orders

Got it solved. Probably not the most efficient way but it works! SELECT product_id, meta_value FROM ( SELECT order_meta.order_item_id, order_meta.meta_value AS ‘product_id’ FROM wp_woocommerce_order_itemmeta AS order_meta LEFT JOIN wp_woocommerce_order_items AS order_items ON order_meta.order_item_id = order_items.order_item_id LEFT JOIN wp_term_relationships AS term_rels ON term_rels.object_id = order_items.order_id WHERE term_taxonomy_id = 24 AND order_meta.meta_key = ‘_product_id’ ) AS product_ID … Read more