Help with customising love it plugin (use within foreach)

A couple of problems- setup_postdata doesn’t work with any variable other than $post, so that line is doing nothing. This is explained on the Codex page for setup_postdata. get_the_ID doesn’t accept any arguments, but it doesn’t matter, you’ve already got the ID in $event->ID, just change all instances of get_the_ID($event->ID) to $event->ID.

How to send json data to jquery

You could use one of these. It would give you json data. $data = json_encode( array(‘status’ => 200, ‘message’ => ‘success’); $result = wp_send_json_success( array( ‘photo_id’ => $photo_id_encode,’upload_msg’ => ‘Success’ ) );

How to pull data from a table using wpdb?

First, you want to use the global $wpdb variable. global $wbdp; Then set up your query. Make it a separate variable so you can output it and check for syntax errors. $my_query = $wpdb->prepare( /* SQL query here */ ); Then execute the query. $results = $wpdb->get_results( $my_query );