Shortcodes
-
Hello there,
I’m not sure if anyone is able to help me but I’m trying to create a shortcode that will display a list of upcoming events in date order from the _EventStartDate meta.
Here is what I have so far…
/************************************************************************* * Shortcode - What's Next *************************************************************************/ add_shortcode('jmit_events_whatsnext', 'jmit_events_whatsnext_shortcode'); function jmit_events_whatsnext_shortcode(){ global $post; ob_start(); $args = array( 'posts_per_page' => 2, 'post_type' => 'tribe_events' ); $lastposts = get_posts( $args ); foreach ( $lastposts as $post ) : setup_postdata( $post ); ?> <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <?php the_content(); ?> <?php endforeach; wp_reset_postdata(); $myvariable = ob_get_clean(); return $myvariable; }However it does not appear to respond to the ‘posts_per_page’ argument, it just lists every event.
Has anyone got any ideas or pointers?
Thanks very much!
Jason
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Shortcodes’ is closed to new replies.