Search query with Ajax

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 });

WordPress Insert not working with ajax

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

How to Generate a list of Most Commented post?

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

How to get DB options format without saving? [closed]

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

WPDB SQL Ignore `post_status` Parameter

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

wpdb and acf via wp rest api

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

Why my query does not run with prepare

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

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