How to show all events on one page

This topic contains 4 replies, has 2 voices, and was last updated by  Cindy 9 years, 6 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #3309

    Hey,

    I created a list of events and want it to show all events on one page (rather than just 5 at once). I know that I’ve already read it somewhere here, but I can’t remember where and I don’t seem to be able to find it again.

    So can you please post the piece of code (and where to put it exactly) for that again?

    Thank you

    Cindy
    #3310

    You can use the eo_events shortocde (see docs), and set the numberposts attribute to -1.

      `[eo_events numberposts=-1 showpastevents=true]`
    
    Stephen Harris
    #3342

    Yeah thanks. I already knew about the shortcode, but I want to change it in the event-archive.php so that I can create a menu and the event list is shown there

    (Maybe it’s easier to understand if I just give you the link:
    http://potpourridersensationen.de

    You can see the Menu ‘OSCAR BUZZ 2013 – SCHEDULE’ on the top

    If you click on that you see 5 Events, an the next/prev Buttons (I don’t know why the default gives them to me twice, but be it as it may, since I only want one list anyway). Now, I only want them all to be seen on one page, but I don’t know where to insert the short code. Since I only created a menu button that links to the page http://potpourridersensationen.de/events/event/ there is nowhere to insert it there. That’s why I wanted to change it in the event-archive.php)

    Hope, I could make myself clear. I don’t know how to explain it better. I’m sorry.

    Cindy
    #3343

    Ok, then the following should do what you’re after. Ideally it should go in a ‘site functionality plugin’ (see this article: http://wpcandy.com/teaches/how-to-create-a-functionality-plugin/). Alternatively you can put it in your (child) theme’s functions.php. You shouldn’t edit the plug-in files as changes will be lost when you update – and putting it in template files is ‘too late’ for the code to take effect.

     add_action( 'pre_get_posts', 'cindy_show_all_events' );
     function cindy_show_all_events( $query ){
          if( $query->is_main_query() && 'event' == $query->get( 'post_type' ) ){
                   $query->set( 'posts_per_page', -1 );
          }
     }
    

    Hope that helps!
    Stephen

    Stephen Harris
    #3349

    Yeah. it worked. Thanks a lot!

    Cindy
Viewing 5 posts - 1 through 5 (of 5 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.