I need to know how do i get an Event Post with Ajax (wp-admin.php)

Home Forums Ticket Products Event Tickets Plus I need to know how do i get an Event Post with Ajax (wp-admin.php)

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1136339
    Patricia
    Participant

    Just before i start to use Event Tickets plus i used this code:

    
    	function ct_get_event() {
    		
    		$post_id = $_POST['post_id'];
    		$query = new WP_Query( 'p='.$post_id );
    		
    		if ( $query->have_posts() ) :
    			while ( $query->have_posts() ) : $query->the_post();
    				the_title();
    				the_content();
    			endwhile;
    		else:
    			echo 'no posts found';
    		endif;
    	}
    	add_action('wp_ajax_get_event', 'ct_get_event');
    	add_action('wp_ajax_nopriv_get_event', 'ct_get_event');
    

    But now its obsolete, can u tell me how to do the request with single-event template?

    #1136516
    Brook
    Participant

    Howdy Patricia,

    I would love to help you with this.

    I am not sure what about that code is obsolete, it looks pretty solid to me. When you run the request do you get “no posts found”? Or, does something else happen?

    Cheers!

    – Brook

    #1137454
    Patricia
    Participant

    I get “no posts found” I need to bring the event with its template via ajax, this code only gets me posts

    #1138004
    Patricia
    Participant

    Let me explais again, this code is queryng a post as it, i need to know what modifications i need to do, to get the single event post with the single-event.php template

    #1138548
    Brook
    Participant

    Ahh Okay, I understand. Thank you for clarifying.

    single-event.php has not support for Ajax builtin. You would have to build that basically from the ground up.

    Where our plugins typically add support for ajax is within the “Template_Factory” we use. For example in /the-events-calendar/src/Tribe/Template/Month.php you will see the template factory used to produce Month View. It’s no small beast. There are number of portions of it that add Ajax support, but the bulk of it is within the ajax_response() located near the bottom of that file. You could add something like this for Month View if you were so keen. It would likely take a 2+ hours of dev work to do and get working well though, assuming you or you web developer are pretty versed in such things.

    I hope that info helps! I wish this wasn’t such a time consuming feature to build and I could just give you some exact code! Let me know if you have any questions along the way.

    Cheers!

    – Brook

    #1146668
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘I need to know how do i get an Event Post with Ajax (wp-admin.php)’ is closed to new replies.