Why excerpt hook not working inside ajax function?
Why excerpt hook not working inside ajax function?
Why excerpt hook not working inside ajax function?
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
LOL– I had to just add posts_per_page in my $terms_year query. Leaving this up in case people need it… $terms_year = array( ‘post_type’ => array(‘publications’), ‘posts_per_page’=>-1, );
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
You’ll want to use the % math operator. if ( $currentPost % 5 === 0 ){ echo “Ad Space</br>”; }
WordPress next post by ajax call on button click
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
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
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
Cannot pass value variable to WP AJAX functions