How to get WooTickets to show in main blog loop

Home Forums Ticket Products Event Tickets Plus How to get WooTickets to show in main blog loop

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1000336
    Hannah
    Participant

    Hey,
    I got the events to show in the main blog loop, however I also need the wootickets form on the main page posts and I”m not really sure how to get it there.
    I’m pretty sure this isn’t a bug or conflict, it just looks like whatever the plugin looks for to post the form isn’t part of the blog version of events.

    Thanks

    #1000622
    Geoff
    Member

    Hey Hannah and welcome to the forums. 🙂

    Good question and you’re absolutely right: adding events to the site’s main post query will simply format events to the main post type, as it’s formatted in the template containing the loop for your homepage.

    If you want, you can add the ticket form to the template’s loop using something like:

    if ( tribe_is_event && tribe_events_has_tickets ) {
    echo tribe_get_ticket_form();
    }

    Place that in the loop where you would like the ticket form to display and it should fetch the ticket form if the post is an event and has tickets available.

    Cheers!
    Geoff

    #1000775
    Hannah
    Participant

    Hey Geoff,

    I tried putting to code in the loop’s template file but it still doesn’t show up. I just stuck it after the main content (see below), did I do it wrong? Or can it not tell that the post was an event post. The page still functions so I don’t think I broke anything.

    	<div class="entry-content">
    		<?php if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
    			the_post_thumbnail();} 
    		?>
    		<?php
    			the_content( sprintf(
    				/* translators: %s: Name of current post. */
    				wp_kses( __( 'Continue reading %s <span class="meta-nav">&rarr;</span>', 'piggyback' ), array( 'span' => array( 'class' => array() ) ) ),
    				the_title( '<span class="screen-reader-text">"', '"</span>', false )
    			) );
    		?>
    		<?php if ( tribe_is_event && tribe_events_has_tickets ) {
    			echo tribe_get_ticket_form();
    		} ?>
    	</div><!-- .entry-content -->
    #1000881
    Geoff
    Member

    Hi Hannah,

    Oh shoot, I think I have led you down a wrong path and I’m super sorry!

    Getting the ticket form in the content of the post in the homepage feed is quite a tricky task. However, one option you might consider is displaying information that tickets are available, if there are any. For example:

    <?php if ( tribe_is_event() && tribe_events_has_tickets() ) {
    echo '<p>' . tribe_events_count_available_tickets() . ' Tickets Available</p>';
    } ?>

    This will show how many tickets are available for a ticket, if there are tickets at all.

    You can use that same condition to style an event with tickets differently than regular posts or even other events that do not have tickets to distinguish things even further.

    Sorry for striking out the first time, but does this help instead? Please let me know. 🙂

    Thanks!
    Geoff

    #1000890
    Hannah
    Participant

    How tricky are we talking? Linking through to the ticketing page is a workable solution, but if getting the tickets on the homepage is possible I wouldn’t mind having a whack at it.

    Thanks for all your help insofar.

    #1000903
    Geoff
    Member

    I think it’s tricky enough to require including other templates into the template with the content loop and possibly even enqueuing scripts to make it happen. I’m afraid it would be well outside the level of customization we would be able to support here in the forums.

    So, linking the snippet I provided before would look something like this:

    <?php if ( tribe_is_event() && tribe_events_has_tickets() ) {
    echo '<p><a href="' . esc_url( tribe_get_event_link() ) . '">' . tribe_events_count_available_tickets() . ' Tickets Available</a></p>';
    } ?>

    Geoff

    #1001118
    Hannah
    Participant

    Alrighty then, thanks for the link solution, works like a peach.

    Hannah

    #1001207
    Geoff
    Member

    My pleasure and thanks for letting me know! I’ll go ahead and close this thread but please do feel free to hit us up with a new one if any other questions pop up and we’d be happy to help. 🙂

    Cheers!
    Geoff

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘How to get WooTickets to show in main blog loop’ is closed to new replies.