• Resolved patrickpoutou

    (@patrickpoutou)


    Hello,
    I am trying to use EM_categories to display a menu who only have the categories of next events. But it doesn’t use the scope. So all the categories who have had an event, eve passed, is displayed, which I find strange (what’s the use of displaying the categories of passed events ?). I tried to find an answer here, but I didn’t.

    echo EM_Categories::output(array( 'scope'=>'future', 'exclude' => '86', 'hide_empty'=> '1'))

    Do I miss something (I think I do 😉

    Thanks for your help.

    Patrick

    https://wordpress.org/plugins/events-manager/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support angelo_nwl

    (@angelo_nwl)

    you can try something like

    $EM_Categories = EM_Categories::get($args);
    foreach( $EM_Categories as $EM_Category ){
    
      echo $EM_Category->output('#_CATEGORYNAME');
    
    }
    Thread Starter patrickpoutou

    (@patrickpoutou)

    Thanks for the answer.
    Your code does exactly the same : it lists all categories, even those with only passed events. (Of course I add a scope =>future in the $args).

    So I did this, but it seems very raw to me 😉 And I think it does a lot of queries !

    $events = EM_Categories::get(array('hide_empty'=> '1'));
    Global $CatsIds;
    foreach($events as $Cats){
    	$categorie = $Cats->id;
    	$events_count = EM_Events::count( array('category'=>$Cats->id, 'scope'=>'future') );
    	if ($events_count > 0) $CatsIds.="$categorie, ";
    }
    $args = array('orderby' => count,'order' => DESC,'taxonomy' => 'event-categories','include'  => $CatsIds,);
    wp_list_categories( $args );

    Thanks again for your trying.

    Patrick

    I think the problem here is that scope isn’t available for use with EM_Categories.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Catagories and scope’ is closed to new replies.