Home › Forums › Calendar Products › Events Calendar PRO › Pull 4 Events from a Specific Category
- This topic has 4 replies, 2 voices, and was last updated 10 years, 6 months ago by
George.
-
AuthorPosts
-
October 23, 2015 at 11:13 am #1017392
Mary Correia-Moreno
ParticipantI’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; ?>October 23, 2015 at 11:29 am #1017403George
ParticipantHey @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
October 23, 2015 at 2:21 pm #1017474Mary Correia-Moreno
ParticipantHi 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>October 23, 2015 at 2:42 pm #1017486Mary Correia-Moreno
Participantnevermind! 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>October 26, 2015 at 11:28 am #1018048George
ParticipantNice! Thanks for sharing your solution 😀
Cheers,
George -
AuthorPosts
- The topic ‘Pull 4 Events from a Specific Category’ is closed to new replies.
