• I ran into a bug with The Events Calendar dealing with limiting the number of events listed in “list view.”

    I’ve created a custom query on my home page to list the 5 next upcoming events:

    <?php query_posts('category_name=Featured Events&posts_per_page=5&eventDisplay=upcoming'); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class="post">
            <div class="graphic">
                <div class="month m-<?php echo the_event_start_date(d,d,'m'); ?>"></div>
                <div class="date d-<?php echo the_event_start_date(d,d,'d'); ?>"></div>
            </div>
            <h3><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
            <div class="entry">
                    <?php the_excerpt(); ?>
            </div>
    </div>
    <?php endwhile; ?>
    
    <div class="moreLink">
        <a href="<?php bloginfo('siteurl'); ?>/category/events/" title="View more events.">More events &raquo;</a>
    </div>
    
    <?php else: ?>
        <div id="noPosts">
            No upcoming events at this time.
        </div>
    <?php  endif; ?>

    I noticed that using posts_per_page=5 in the query does not work. You have to change the “Blog pages show at most” setting in the Reading Settings for the blog to limit the number of Event posts displayed. This in itself is annoying, as I do not want to limit every post page to 5 posts. Is there any to get the posts_per_page argument to work?

    Anyways, the actual bug lies in the fact that when you do change the “Blog pages show at most” setting, for some reason it also limits the number of posts displayed in the back-end admin panel. In the admin panel, If you navigate to Posts, and then filter all of your posts by the “Events” category, it only displays 5 posts. It also does not provide the normal pagination to view the rest of the posts.

    So, you can’t access all the post in the “events” category while filtering the posts by a category. You can only edit these posts by flipping through the pages for all posts.

    Has anyone else run into this? Is this an issue with the plugin or WordPress?

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter David Calhoun

    (@dpcalhoun)

    Hi,

    Using the WP_Query object for the custom loop solves this for me. In your first line, instead of using query_posts(), replace that call with the following:

    <?php
       $upcoming_events_args = array( 'category_name'=>'Events', 'posts_per_page'=>'5', 'eventDisplay'=>'upcoming' );
       $upcoming_events_query = new WP_Query( $upcoming_events_args );
    ?>

    Then change the beginning of the loop to call from the WP_Query instance, so replace the second line with:

    <?php if($upcoming_events_query->have_posts()) : while ($upcoming_events_query->have_posts()) : $upcoming_events_query->the_post(); ?>

    Justin

    Thread Starter David Calhoun

    (@dpcalhoun)

    Thanks a lot, Justin. That did just the trick. The backend even works now as well. I can filter posts by category and see all of them. So, I guess it really isn’t an actual bug.

    Thanks again.

    Thread Starter David Calhoun

    (@dpcalhoun)

    Just realized that my events feed is now no longer displaying the events in order of event date. Know of a way to fix this?

    I tried 'order'=>'asc' but that cause all past events to be displayed. According to The Events Calendar plugin page just eventDisplay=upcoming should order them by event date.

    Thread Starter David Calhoun

    (@dpcalhoun)

    I tried:

    http://yourUrl.com/feed?eventDisplay=upcoming

    for the feed url and it worked. Is this what you’re after? If not, can you post a link to your site?

    Justin

    I also had this problem with a theme that uses a recent category loop, and used justin’s wp query solution – like dp I now get the number of posts I want on the page(1), but it did not list in order, and using the eventDisplay=upcoming grabs the last upcoming event (the event furthest out) rather the most recent upcoming event. Any solutions?

    *bump.

    Experiencing the same problem here…. justinendler’s code works to limit the number of events displayed, but for me, the date disappears, and the events are not in upcoming order by date….

    Solution, anyone?

    I have also the same problem here. I’ve read that the default settings of Event displayed is 10. I’ve looked into the plugin folder and I have found out that this 'post_per_page', 10 included in template-tags.php (under the function get_events)

    It’s also mentioned in the notes of the plugin that the display could be altered by ‘the $count parameter to get_events().’

    Would be happy if some1 could figured this problem, it’s been hours and hours for me to try to find this solution (limit the events displayed while also listing in upcoming display order)

    ok.. I have found the solution for this problem post_per_page=5&eventDisplay=upcoming to work. I simply limit the while loop with the $counter based on php code.

    This is the opening code for the query for displaying 5 recent upcoming events

    <?php query_posts('category_name=events&eventDisplay=upcoming');?>
     <?php $my_query = new WP_Query('category_name=events'); ?>
     <?php while ( have_posts() & $counter <= 4 ) : the_post(); ?>

    and just before the <?php endwhile; ?> add this code
    <?php $counter = $counter + 1; ?>

    I’m pretty sure this will solve everyone problems here =D

    Laurentius

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[Plugin: The Events Calendar] BUG: Limiting Number of Events Listed’ is closed to new replies.