WordPress conflict with multiple load more posts functions on click

check your portfolio-scripts.js and blog-scripts.js both action contain same action. ‘action’: ‘load_more_posts’, So for your portfolio-scripts.js action Should be ‘action’: ‘loadmore_portfolio_posts’, instead of ‘action’: ‘load_more_posts’, You declare the function in portfolio-scripts.php but not call in the ajax. I guess change the action solve your problem.

A javascript function that simply runs a php function on the plugin

In your JS code, you need an action so it knows what function to execute. var data = { ‘action’: ‘my_action’, ‘nothing’: ‘nothing’ ‘whatever’: ajax_object.we_walue } You should see how the action corresponds to the hook you used in add_action. But I would also add a second action: add_action(‘wp_ajax_my_action’, ‘back_php’); add_action(‘wp_ajax_no_priv_my_action’, ‘back_php’); This will ensure … Read more

WP_Query extended with AJAX

this is my geo_query extension of wp_query: add_filter( ‘posts_fields’, ‘willy_geo_fields’, 10, 2 ); function willy_geo_fields( $fields, $q ) { if ( isset( $q->query_vars[‘geo_query’][‘latfrom’], $q->query_vars[‘geo_query’][‘lngfrom’], $q->query_vars[‘geo_query’][‘latto’], $q->query_vars[‘geo_query’][‘lngto’], $q->query_vars[‘geo_query’][‘distancefrom’], $q->query_vars[‘geo_query’][‘distanceto’] ) ) { global $wpdb; $fields .= $wpdb->prepare(“, ( 6371 * acos( cos( radians( %f ) ) * cos( radians( metalatfrom.meta_value ) ) * cos( radians( metalngfrom.meta_value … Read more

Find the method which AJAX GET calls

If the url is something like this admin-ajax.php?example_ajax_request=1&data=1234 The add_action function in the code would be wp_ajax_nopriv_example_ajax_request So, try to grep the whole of your theme directory or plugin directory for the text. Example: grep -r ‘wp_ajax_nopriv_example_ajax_request’ * The second parameter of the add_action is the function name you’re looking for. See https://codex.wordpress.org/AJAX_in_Plugins#Ajax_on_the_Viewer-Facing_Side for example … Read more

Cannot access class properties from ajax call in wpordrpess

The problem was caused by another method inside the class: public function create_cart_id() { if( is_user_logged_in() ) { $this->create_logged_in_cart_id(); }else { $this->create_non_logged_in_cart_id(); } return $this->cart_id; – adding that line solved the problem } This method generates the $cart_id, but it didn’t return its value, so it was not accessible from outside and returned null.