Pull 4 Events from a Specific Category

Home Forums Calendar Products Events Calendar PRO Pull 4 Events from a Specific Category

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1017392
    Mary Correia-Moreno
    Participant

    I’d like to display the four upcoming events from a category titled “chamber” – is there a way to modify my loop to only pull the events from that specific ‘chamber’ category?

    <?php $args = array( 'post_type' => 'tribe_events', 'posts_per_page' => 4 );
    	$loop = new WP_Query( $args );
    	while ( $loop->have_posts() ) : $loop->the_post(); ?>
    	<li>
    		<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
    			<?php the_title(); ?>
    		</a>
    	</li>
    <?php endwhile; ?>
    #1017403
    George
    Participant

    Hey @William,

    Just as a disclaimer, we do not offer any support for custom code here – just wanted to put that right out front 🙂

    I’m happy to try and help though! Instead of WP_Query, I’d recommend using our tribe_get_events() function instead → https://theeventscalendar.com/knowledgebase/using-tribe_get_events/

    Check that out and try using that function instead – something like this should work:


    $events = tribe_get_events( array(
    'eventDisplay' => 'custom',
    'posts_per_page' => 4,
    'tribe_events_cat' => 'chamber'
    ) );

    I hope that helps!

    — George

    #1017474
    Mary Correia-Moreno
    Participant

    Hi George

    I know you can’t provide coding assistance but the above isn’t working … :/ is there anyway to instead show ALL posts but exclude a specific category “community” ??

    any help is greatly greatly appreciated!!! i’m completely stumped over here – again this is what i started with:

    <ul>
    	<?php $args = array( 'post_type' => 'tribe_events', 'posts_per_page' => 4 );
    		$loop = new WP_Query( $args );
    		while ( $loop->have_posts() ) : $loop->the_post(); ?>
    		<li>
    			<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
    				<?php the_title(); ?>
    			</a>
    		</li>
    	<?php endwhile; ?>
    </ul>
    #1017486
    Mary Correia-Moreno
    Participant

    nevermind! figured out a work around, just using tags instead:

    <ul>
    	<?php $args = array( 'post_type' => 'tribe_events', 'posts_per_page' => 4, 'tag' => 'chamber' );
    		$loop = new WP_Query( $args );
    		while ( $loop->have_posts() ) : $loop->the_post(); ?>
    		<li>
    			<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
    				<?php the_title(); ?>
    			</a>
    		</li>
    	<?php endwhile; ?>
    </ul>
    #1018048
    George
    Participant

    Nice! Thanks for sharing your solution 😀

    Cheers,
    George

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Pull 4 Events from a Specific Category’ is closed to new replies.