Export SQL query based on custom field?

Change your query to: SELECT wp_posts.* FROM wp_posts INNER JOIN wp_postmeta ON wp_postmeta.post_ID = wp_posts.ID WHERE ( wp_postmeta.meta_key = ‘Color’ AND wp_postmeta.meta_value IS NOT NULL ); That way it only gets the data in wp_posts, but still filters based on your criteria.

Php Mysql Terms

What you just found in your database is the serialized form of an array. For the sake of understanding the concept, see the PHP manual on the serialize function. As an aside: Apart from the fact, that you found this in a WP database though, this question is not WP specific and actually beyond the … Read more

Most viewed posts in WordPress

http://www.catswhocode.com/blog/super-useful-wordpress-hacks-and-snippets You source? I made a widget that does just that, on this same code. To sort: <?php $args = array( ‘post_status’ => ‘publish’, ‘meta_key’ => ‘post_views_count’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘ASC’ ); $the_query = new WP_Query($args); //http://codex.wordpress.org/Class_Reference/WP_Query //the loop while ( $the_query->have_posts() ) : $the_query->the_post(); //do your magic endwhile;

How to display results from a data table with an encrypted user id?

The plugin now works as I would like, with a little alteration. Instead of setting submitter_id to a random value, it is now set to the logged in user’s id. This will allow displaying other users’ answers. The + indicates new lines of code in the output_quiz.php file: function wpss_getQuiz($quiz_id){ global $wpdb; + global $current_user; … Read more

Query the links Database

WordPress adds prefixes to tables names, which was setup on installation. So by default there is wp_ prefix for tables names. It means that by default table name for links will be wp_links. But you shouldn’t care about standard tables name, because all of them exists as parameters of wpdb class (read Table section), so … Read more

PHP variables in mysql query

To insert a new row: global $wpdb; $wpdb->insert( ‘wp_mytable’, array( ‘product’ => $product ), array( ‘%s’ ) ); For the sake of completeness, $wpdb->update is used to update an existing row and requires an additional WHERE clause, as would a “regular” SQL query. For example: global $wpdb; $wpdb->update( ‘wp_mytable’, array( ‘product’ => $product ), array( … Read more