quotes problem in very simple sql

if you’re communicating with the WordPress database itself, try using $wpdb->prepare() on your select string before running it as $wpdb->query() – it should format it for you. Further reading: Codex

Fetching review value using wpdb class

You need to add the global $wpdb reference and also add the second parameter required for prepare(): global $wpdb; $post_id = $post->ID; $reviewScore = $wpdb->query( $wpdb->prepare( “SELECT review FROM {$wpdb->prefix}gdsr_data_article WHERE post_id = %d”, $post_id ) );

post id not displaying

You call your header.php file by calling get_header() function in single.php file. It means that your $postid_profile variable exists only in scope of get_header() function. To make it visible in global scope you need to make your variable global. So your code should be modified like this: ### get the author info global $current_user, $postid_profile; … Read more

Show array of meta_value in Edit Post Coloum

The error was here: (Thank you @Rarst) if ($column_name == ‘custom_checkbox_group_sesso’) { $sesso_occupanti = get_post_meta($post_ID, “custom_checkbox_group_sesso”, true); //check that we have a custom field if ($sesso_occupanti != “”) { // Separate our comma separated list into an array $sesso_occupanti = explode(“,”, $sesso_occupanti); //loop through our new array foreach ($sesso_occupanti as $sesso) { echo $sesso ; … Read more

Export all posts to import as product items

You don’t have to export and then re-import, you can do it all via the API in one go, no XML required. here’s a quick example plugin: <?php /* Plugin Name: WPA_convert_types */ function wpa_convert_types_page() { add_management_page( ‘WPA convert types’, ‘WPA convert types’, ‘manage_options’, ‘wpa_convert_types’, ‘wpa_convert_types_render_page’ ); } add_action(‘admin_menu’, ‘wpa_convert_types_page’); function wpa_convert_types_render_page() { if( isset( … Read more

How to delete ALL comments from certain category in WordPress database?

The wordpress database seems fairly straight forward and is extremely well documented: http://codex.wordpress.org/Database_Description It seems to me that all the category information is stored in the table wp_term_relationships. So you should select from the comments table, join it with the posts table and then the term_relationships table in order to get the category for each … Read more

WordPress SQL JOIN query

If you are going to do this is SQL, use a subquery. SELECT *, (SELECT meta_value FROM wp_commentmeta WHERE meta_key = ‘your-meta-key’ AND wp_commentmeta.comment_id = wp_comments.comment_ID LIMIT 1) as comment_author FROM wp_comments Instead of the *, enumerate the fields you want but leave out comment_author. Obviously, $wpdb functions to keep the table names straight.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)