show product not tickets

Home Forums Ticket Products Event Tickets Plus show product not tickets

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1192094
    Riccardo
    Participant

    Hi,
    I want display some product there aren’t ticket.
    so what is the right query?
    <?php
    $args = array(
    'post_type' => 'product',
    'posts_per_page' => 50,
    );
    $loop = new WP_Query( $args );
    if ( $loop->have_posts() ) {
    while ( $loop->have_posts() ) : $loop->the_post(); ?>

    " title="<?php the_title(); ?>">

    <?php the_title(); ?>

    <?php
    endwhile;
    } else {
    echo __( 'No products found' );
    }
    wp_reset_postdata();
    ?>

    If I use this it show all the products.
    thanks

    #1192417
    Andras
    Keymaster

    Hello Riccardo,

    Thanks for using our plugins and for reaching out!

    We are limited in supporting customization but I can try to point you in the right direction.

    Yes, the query above will show all the tickets as well, as they are also products.

    You could try to do the following:

    Filter out (and now show) those products where in the wp_postmeta table the meta_key _visibility is hidden and meta_key _virtual is yes. These are the attributes that the tickets have.

    Or another way would be, if the product has a meta_key named _tribe_wooticket_for_event, then it is a ticket, so don’t show it.

    I hope this helps you get started. Let me know.

    Cheers,
    Andras

    #1192619
    Riccardo
    Participant

    Hi Andras,
    this is how I try.

    'posts_per_page' => 50,
    			'post_status'    => 'publish',
    			'post_type'      => 'product',
    		//	'meta_key' => '_tribe_wooticket_for_event',
    			// PETTE escludo tutti gli articoli che non hanno meta_key _tribe_wooticket_for_event'
    			'meta_query' => array(
    							
    							array( 
    								'key'=>'_tribe_wooticket_for_event',
    								'compare' => 'NOT EXISTS'           
    							)
    						),
    			
    			
    			);

    Is it another right way?
    Thanks

    #1193125
    Andras
    Keymaster

    Ciao Riccardo,

    Yeah, I believe this should be fine. Let me know how it works out.

    Cheers,
    Andras

    #1193140
    Riccardo
    Participant

    Thanks!

    #1194158
    Andras
    Keymaster

    No problemo! Happy it helped.

    Since this is marked resolved I am going to close this ticket, but if you need anything else related to this topic or another please post a new topic in the forum and we will help you out.

    Cheers,
    Andras

    PS: If you like our plugin, and you didn’t yet do so 🙂 we would be happy to receive a review in the wordpress.org repository. Thanks!
    https://wordpress.org/support/view/plugin-reviews/the-events-calendar

    PS2: We’d be also grateful if you would give us feedback on your satisfaction with support. Just click on one of the classy looking emojis below. 🙂 If you can spare a few words, that’s even better. Doublethanks!

     

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘show product not tickets’ is closed to new replies.