Showing different number of events in different views

Home Forums Calendar Products Events Calendar PRO Showing different number of events in different views

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #122082
    karganmedia
    Participant

    <p>Hi</p>
    <p>I have a client that wants to show about 50 event pins on Map View. The only way I have been able to manage this is to actually set the number of events in the plugin settings to the total number of events listed. This of course means that when going to List View all events are shown, however, I want to limit this view to 8 per page.</p>
    <p>I found the following code to place in the functions file in this forum which works brilliantly, however, also effects the number of related events… which now also shows 8 instead of 3.</p>
    <p>
    //show more events on the events list pages</p>
    <p>add_action( ‘pre_get_posts’, ‘set_events_per_page’ );
    function set_events_per_page( $query ) {
    if ( $query->query_vars[‘eventDisplay’] == ‘upcoming’ || $query->query_vars[‘eventDisplay’] == ‘past’ && $query->query_vars[‘post_type’] == TribeEvents::POSTTYPE && !is_tax(TribeEvents::TAXONOMY) && empty( $query->query_vars[‘suppress_filters’] ) ) {
    $query->set(‘posts_per_page’, 8);
    }
    return $query;
    }
    </p>
    <p>So 2 questions:</p>
    <p>1. Is it somehow possible to show all event pins on the map and still have only 8 events listed on the Map View pages.</p>
    <p>2. or is it possible to adjust the above code so that in List View 8 events are listed but Related Events remain at 3… assume it’s something to do with !is_tax(TribeEvents::TAXONOMY)… but couldn’t get it to work.</p>
    <p>Many thanks</p>

    #122083
    karganmedia
    Participant

    Opps… sorry about the html markup but when viewing my discussion in preview mode everything ran together so added the markup which I obviously didn’t need to do!

    #122690
    Barry
    Member

    No worries, there are a few glitches with the forum at present and we’re addressing them as quickly as we can – apologies for any confusion that stemmed from the preview.

    Showing 50 pinmarkers but only 8 events is probably possible – but it’s going to be a comparatively advanced customization that, realistically, is beyond what we can help you with here.

    Selectively applying the snippet you referenced, though, so it’s only used on map view probably is a little easier: could you try adding a call to tribe_is_map() at the start of your action function and, if it returns false, simply bail out? For example:

    function set_events_per_page( $query ) {
        if ( ! tribe_is_map() ) return; 
        /* ... rest of your code ... */
    }

    Would that work for you here?

    #129516
    Barry
    Member

    This thread’s not seen much activity for the last couple of weeks so I’ll go ahead and close it. Of course if you still need help with this or any other issue please don’t hesitate to create a new thread (or threads) and one of the team will be only too happy to help. Thanks!

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Showing different number of events in different views’ is closed to new replies.