WordPress e database query

Un piccolo repositorio con select dirette sul mysql.

[http://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query]

$querystr = “SELECT $wpdb->postmeta.*
FROM $wpdb->postmeta
WHERE $wpdb->postmeta.meta_key = ‘progetto_cliente’
AND $wpdb->postmeta.meta_value = $idCliente “;

“SELECT post_title FROM $wpdb->posts WHERE post_status = ‘publish’ ORDER BY post_date DESC”

$wpdb—>get_col(“SELECT post_title FROM $wpdb->posts WHERE post_status = ‘publish’ ORDER BY post_date DESC”);  

“SELECT post_title, post_date FROM $wpdb->posts WHERE post_status = ‘future’ ORDER BY post_date DESC”

PUT NEWS VALUES INSIDE

global $wpdb;
$term_id = 100; // note that this may need to be adjusted based on the ID’s in your table
$name = ‘Code Snippet’;
$slug = ‘code-snippet’;
// add the new category
$query = “INSERT INTO $wpdb->terms (term_id, name, slug) VALUES (%d, %s, %s)”;
$wpdb->query($wpdb->prepare($query, $term_id, $name, $slug));
// create the relationship
$term_taxonomy_id = 100;
$taxonomy = ‘category’;
$query = “INSERT INTO $wpdb->term_taxonomy (term_taxonomy_id, term_id, taxonomy) VALUES (%d, %d, %s)”;
$wpdb->query($wpdb->prepare($query, $term_taxonomy_id, $term_id, $taxonomy));

MODIFY VALUES

$wpdb->update(“$wpdb->term_taxonomy”, array(‘taxonomy’ => ‘category_demo’), array(‘taxonomy’ => ‘post_tag’));

MORE RESOURCES

[http://thecustomizewindows.com/2011/03/indispensable-mysql-queries-for-custom-fields-in-wordpress/]

[http://speckyboy.com/2011/03/23/20-helpful-wordpress-sql-queries-snippets/]

[http://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query]

SNIPPETS

[http://www.wphub.com/101-useful-wordpress-snippets/]