ajax stopped working when not logged in wordpress

Try to output the debug query Find fragment $the_query = new WP_Query( array( ‘posts_per_page’ => 5, ‘s’ => esc_attr( $_POST[‘keyword’] ) ) ); if( $the_query->have_posts() ) : Replaced by $the_query = new WP_Query( array( ‘posts_per_page’ => 5, ‘s’ => esc_attr( $_POST[‘keyword’] ) ) ); echo (string)$the_query->request; if( $the_query->have_posts() ) : Perhaps some hooks are triggered … Read more

Search function – problem with whole words

Exact means exactly that – the whole field must match, not just a word in the field. To get whole words that are part of the field, remove ‘exact’ => 1 Add this if ($_POST[‘terms’]) { $keyword = sanitize_text_field( $context[‘terms’] ); $keyword = ‘[[:<:]]’ . $keyword . ‘[[:>:]]’; $context[‘posts’] = Timber::get_posts(array( // other params here … Read more

“add to cart” links css class “ajax_add_to_cart” doesn’t show in woocommerce in widget sidebar

At last i solved it myself. Hope someone will get benefit form this answer. I merge $default variables all array (quantity, class, attributes) directly into link. I changed whole block of if ( $product ) {}. if ( $product ) { $output .= sprintf( ‘<a href=”%s” data-quantity=”1″ class=”%s” %s>%s</a>’, esc_url( $product->add_to_cart_url() ), esc_attr( implode( ‘ … Read more

Ajax Call not Working in Plugin

You need to add the ajax callback action on your plugin file or themes functions.php like as below: add_action( ‘wp_ajax_fetch_data’, ‘fetch_data_callback’ ); add_action( ‘wp_ajax_nopriv_fetch_data’, ‘fetch_data_callback’ ); then you need to put all the featch_data.php code inside the callback function ‘fetch_data_callback’ like as below: function fetch_data_callback(){ //your function code goes here wp_die() // need to add … Read more

do_action won’t work in ajax callback

Note: OP and me resolved the question/issue via chat — and despite the actual problem source is not known for sure, in the actual AJAX callback used by OP, there was actually no (or maybe OP had forgotten to make the) do_action() call. 🙂 Original Revised Answer (for reference): If you have something like so … Read more