Why won’t this wpdb get_results query return results?
When the query was done using ~ (tilda) quotes around columns in the SQL instead of the ‘ it worked. It has something to do with the collation of my tables in MySQL, I believe.
When the query was done using ~ (tilda) quotes around columns in the SQL instead of the ‘ it worked. It has something to do with the collation of my tables in MySQL, I believe.
This is a javascript issue. You have to prevent form submission to stop the page from reloading. See event.preventDefault() in jQuery docs. jQuery(“#Submityourskill”).click(function(event){ event.preventDefault(); // the rest of your code });
Your AJAX callback method should be outputting something followed by a die() statement. function wp_insert() { ..your code echo $whatever_your_results_are; // die(); } I would also recommend against prefixing your custom methods with wp_. That should be reserved for WordPress and will cause confusion to other developers – and probably you 6 months down the … Read more
You can’t use wpdb::prepare to inject table names – just use “SELECT … $sidebar_table”
Primary issue with your function is “get_template_part” internally use global $post variable to display the post fields. However, your $post variable is filled for this function only. I would suggest to read this handy article Displaying Posts Using a Custom Select Query Now, specifically in your case function lugaresincreibles_most_commented() { global $wpdb, $post; // make … Read more
As I mentioned here those 2 ajax actions, here is how you can use the second action that extracts form values in db format Create an ajax action that will return the settings options You can add this code to {theme}/functions.php or to {theme}/inc/hooks.php function _action_ajax_fw_theme_get_settings_options() { wp_send_json_success(array( ‘options’ => fw()->theme->get_settings_options() )); } add_action( ‘wp_ajax_fw_theme_get_settings_options’, … Read more
Well, first of all, you use where post_status=”publish”. So you wouldnt need to explicitly tell the drafts not to show up by using wp_posts.post_status != ‘draft’ I think, your SQL says somthing like: Grab all posts which are published and not drafted and attached to term_id 17 OR grab all posts which are attached to … Read more
I ended up using $wpdb for my custom tables and went with wp_query for my custom posts with ACF fields $q = new WP_Query(array( ‘post_type’ => ‘coupon’, ‘post__in’ => $cids )); $coupons = array(); while($q->have_posts()) : $q->the_post(); $p = get_post(); $f = get_fields(); $m = array_merge((array)$p, (array)$f); array_push($coupons, $m); endwhile; And that’s how the cookie … Read more
Check the codex – wpdb::prepare expects the first argument to be a sprintf syntax string, followed by the arguments to be injected (again, just like sprintf): echo $wpdb->prepare( ‘%s’, $fetch_row );
That is not how $wpdb->prepare works. You feed prepare a string with sprintf-like placeholders, and the appropriate replacement values. Placeholders The query parameter for prepare accepts sprintf()-like placeholders. The %s (string), %d (integer) and %f (float) formats are supported. (The %s and %d placeholders have been available since the function was added to core in … Read more