WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version [closed]

There are multiple ways to fix this. You can either remove the if-condition containing SHOW TABLES LIKE (remove lines: 117, 135 and 137, 157). That should work as the dbDelta function checks itself if the tables are already presend. Or you could just add some single quotes to the table names in the lines 117 … Read more

get data with shortcode

I am not sure about your error as well, but one thing you are doing wrong. Returning data. You should be ‘collecting’ them and then returning. $data=””; foreach ( $results as $result ) { $data .= ‘ Point: ‘.$result.’ ‘; } return $data; Try this loop.

Query custom taxonomy for category including children

tax_query is used to get the posts associated with certain taxonomy. {tax} (string) – use taxonomy slug. Deprecated as of Version 3.1 in favor of ‘tax_query’. tax_query (array) – use taxonomy parameters (available with Version 3.1). taxonomy (string) – Taxonomy. field (string) – Select taxonomy term by (‘id’ or ‘slug’) terms (int/string/array) – Taxonomy term(s). … Read more

Help setting up a sql query

Ok, if i understand you clearly, then this is the solution // first get the post ids that have the breakfast food type $post_ids = $wpdb->get_col( “SELECT DISTINCT post_id FROM $wpdb->postmeta WHERE meta_key = ‘type’ AND meta_value=”Breakfast”” ); // now get the food names $stocktypes = $wpdb->get_col( “SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = … Read more

remove all custom post created

Manipulating posts directly in database is rarely good idea, since it skips all the APIs, hooks and so on that normally participate in the process. You should use get_posts() to retrieve the list and wp_delete_post() for deletion to ensure it is done properly and there are no leftovers.

Getting featured image with direct $wpdb within plugin

That is not how you would query for a featured image. This: $thumb = $wpdb->get_var(“SELECT ID FROM $wpdb->posts where post_parent=”$value” and post_type=”attachment””); Should be: $thumb = $wpdb->get_var(“SELECT meta_value FROM $wpdb->postmeta where meta_key = ‘_thumbnail_id’ and post_id = ‘$value'”); That is assuming that $value is a post ID. “Featured” images are attachments, but not all attachments … Read more

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