Understanding WordPress Search

The default search is handled by WP_Query mostly by a method called parse_search(), which is triggered by the s parameter. You can search the source of WP_Query for is_search and piece together a few other bits and pieces. Or you can just create a query… $s = new WP_Query(array(‘s’ => ‘test’)); … dump the SQL… … Read more

$wpdb->get_var – What value is returned when zero records are found?

First, you’re using prepare() wrong. Should be this: $wpdb->prepare(“SELECT Active FROM testers WHERE user_id = %s”, $user_id) Or even better (%d) represents numeric value as oppose to %s which is string: $wpdb->prepare(“SELECT Active FROM testers WHERE user_id = %d”, $user_id) If you have any debugging enabled, it will throw an error from your code. Which … Read more

How to split the WordPress database?

Coming from a different angle, have you looked into adding indexes to the relevant tables to maximize efficiency? Sometimes the right index can make an amazing difference, even when the files aren’t particularly large. When they are as big as yours the difference could be all you need. You mentioned that you host the server … Read more

Changing host permissions for MySQL users

If you’ve got access to the mysql database, you can change the grant tables directly: UPDATE mysql.user SET Host=”%” WHERE Host=”localhost” AND User=”username”; …and an analogous UPDATE-statement to change it back. Also you might need to make changes to the mysql.db table as well: UPDATE mysql.db SET Host=”%” WHERE Host=”localhost” AND User=”username”; and then flush … Read more

User Tracking for Custom Post Type “Lesson”. Database Queries and Performance

Since there are going to be more than one post (lesson) per user, your code would be more like this: <?php if ( is_user_logged_in() ) { $user_ID = get_current_user_id(); $post_ID = get_the_ID(); $viewed = get_user_meta( $user_ID, ‘viewed_lesson_tracking’, true); if(empty($viewed)){ $viewed = array(); } $viewed[] = $post_ID add_user_meta( $user_ID, ‘viewed_lesson_tracking’, $viewed ); // tracks that user … Read more

Will reducing mysql permissions hinder WP function? [duplicate]

WordPress absolutely does need “DELETE“, otherwise it has no way to delete posts or tags or options rows or anything else. The “DROP” command is sometimes used during upgrades, although it’s been a long time. The last time I think it was used was during the WordPress 2.3 update, which removed the assorted categories tables … Read more