Support » Plugin: Events Manager » Limiting Number of Events Shown In Category

  • Resolved abriel_s

    (@abriel_s)


    I’m currently working on this site, testbuzz.illinimedia.com, having the main navigation be the event categories for the different events.

    As you can see on this category page, the page holding some 30+ events (from what I could tell, since it has a lot of events in this category).

    I’ve tried the following:

    • Going into Events > Settings > Pages > Event List, going to the bottom and inputting 10 as the Events List Limit
    • Going into Events > Settings > Formatting > Event Categories, inputting [events_list limit="10"]#_CATEGORYNEXTEVENTS[/events_list] into the Single category page format
    • Copying the categories-list.php file and changing the following line from this: $args['limit'] = get_option('dbem_categories_default_limit');
      to this: $args['limit'] = '10';

    I can’t find anywhere in the code where the dbem_categories_default_limit variable would be declared so I can change this in here. Or, is there an easier way to write in the categories-list.php file the limit?

    Also, below is the initial code for the categories-list.php file:

    $args = apply_filters('em_content_categories_args', $args);
    $categories = EM_Categories::get( $args );
    //$args['limit'] = '10';
    $args['limit'] = get_option('dbem_categories_default_limit');
    $args['page'] = (!empty($_REQUEST['pno']) && is_numeric($_REQUEST['pno']) )? $_REQUEST['pno'] : 1;
    if( count($categories) > 0 ){
    	echo EM_Categories::output( $categories, $args );
    }else{
    	echo get_option ( 'dbem_no_categories_message' );
    }

    http://wordpress.org/extend/plugins/events-manager/

Viewing 9 replies - 1 through 9 (of 9 total)
  • maybe this will help – http://pastebin.com/MhkCLJkE

    – change location with category
    – change #_LOCATIONNEXTEVENTS with #_CATEGORYNEXTEVENTS

    @agelonwi The code you provided didn’t really do anything to the pages. Here’s the following I pasted up into the categories-list.php file:

    add_filter('em_category_output_placeholder','my_em_placeholder_mod',1,3);
    function my_em_placeholder_mod($replace, $EM_category, $result){
    	switch( $result ){
    	case '#_CATEGORYNEXTEVENTS':
    		$events = EM_Events::get( array('category'=>$EM_Category->category_id, 'scope'=>'future', 'limit'=>3) );
    		if ( count($events) > 0 ){
    			$replace = get_option('dbem_category_event_list_item_header_format');
    			foreach($events as $event){
    				$replace .= $event->output(get_option('dbem_category_event_list_item_format'));
    			}
    			$replace .= get_option('dbem_category_event_list_item_footer_format');
    		} else {
    			$replace = get_option('dbem_category_no_events_message');
    		}
    		break;
    	}
    	return $replace;
    }

    Did I miss something or put it in the wrong location?

    changed

    1.
    function my_em_placeholder_mod($replace, $EM_category, $result){ to function my_em_placeholder_mod($replace, $EM_Category, $result){

    2.
    dbem_category_event_list_item_header_format to dbem_category_list_item_header_format

    3.
    dbem_category_event_list_item_format to dbem_category_list_item_format

    4.
    dbem_category_event_list_item_footer_format to dbem_category_list_item_footer_format

    5.
    dbem_category_no_events_message to dbem_no_categories_message

    Can you be more specific on where I should be placing the code at as well as if any code needs to be replaced? Thanks!

    changed your posted edited snippet with my post above per line.

    I understand that, but I want to know where I place the newly edited code (ex. Em-functions.php)?

    I see, custom snippets should be pasted in your theme functions.php or see this tutorial http://wp-events-plugin.com/tutorials/how-to-safely-add-php-code-to-wordpress/

    Okay now I’m pasting them up in the functions.php file. The first code actually did somewhat of what I wanted. But, it’s not reading in the correct events, and only displays the first three events from today’s events.

    Compare testbuzz.illinimedia.com with the Music category.

    @agelonwl As I mentioned before, the first snippet of code did in fact work. But, it was showing the wrong category. I figured out by looking at the em-category.php file that I simply needed to replace category_id with term_id and it worked!

    In case anyone else is having trouble, here is the solution:

    add_filter('em_category_output_placeholder','my_em_placeholder_mod',1,3);
    function my_em_placeholder_mod($replace, $EM_Category, $result){
    	switch( $result ){
    	case '#_CATEGORYNEXTEVENTS':
    		$events = EM_Events::get( array('category'=>$EM_Category->term_id, 'scope'=>'future', 'limit'=>10) );
    		if ( count($events) > 0 ){
    			$replace = get_option('dbem_category_event_list_item_header_format');
    			foreach($events as $event){
    				$replace .= $event->output(get_option('dbem_category_event_list_item_format'));
    			}
    			$replace .= get_option('dbem_category_event_list_item_footer_format');
    		} else {
    			$replace = get_option('dbem_category_no_events_message');
    		}
    		break;
    	}
    	return $replace;
    }

    I couldn’t have even begun to think of a solution without you, so thank you!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Limiting Number of Events Shown In Category’ is closed to new replies.