Hi, page_per_posts and so on, limit the total number of post displayed as you discovered 🙂
The best solution would probably to loop through each category you want to list and then apply the limit.
Thread Starter
lxm7
(@lxm7)
But ‘limit’ seems like the only syntax made available in the EM output array for altering number of posts. Where / how else could i change the number of output posts per category in this instance? Thanks
I think it’s best to get the category ID for the category you try to display.
I haven’t tried this bit the skeleton would be:
$event_category=get_term_by('name','Foodbank', EM_TAXONOMY_CATEGORY);
$arg = array(
'category' => $event_category->ID,
'order'=>'ASC ',
'limit' => 3,
'format' => 'your format',
);
echo EM_Events::output($arg);
^ that’s the kind of thing I had in mind.
don’t know if this helps but you can also override/modify placeholder #_CATEGORYNEXTEVENTS e.g. http://pastebin.com/tarTctZ7 (just ignore the other filters included in the link)
*paste in your theme functions.php
Thread Starter
lxm7
(@lxm7)
Thanks for the responses, I’ve tried both methods, the first from Peter returns the same issue, it limits to the first 3 of all category list. So the code above for foodbank should have 3 events,it only lists 2, as it will only search the top 3 listed events of any/all categories. (this is whati think is happening as some other category outputs only display 1 or none, as their relavant cat is selected further down the list of the top 3!) For Clarity: I replace ‘your format’ with the code i had initially with the code suggested from peter.
The second method from Angelo displays all the events and then loops through the first 3 events of any category similar to before, even after taking out the while loop. (Note, all this code im editing resides in a file in the inc folder which page.php calls and displays if is page is the relevant one AFTER the default loop used for more basic pages in the site.) I pasted the first block with its filter and edited the code like so:
$event_category=get_term_by('name','ChristChurchKids', EM_TAXONOMY_CATEGORY);
$arg = array(
'category' => $event_category->ID,
'order'=>'ASC ',
'limit' => 3,
'format' => '#_CATEGORYNEXTEVENTS',
);
echo EM_Events::output($arg);
Any other suggestions?! Thanks again.
lxm7, small mistake in my code:
'category' => $event_category->ID,
should be
'category' => $event_category->term_id,
Thread Starter
lxm7
(@lxm7)
Thanks Petervanderdoes, works great now, much appreciated!
NP lxm7, make sure you mark this issue as resolved 🙂
Whoops you did already. Didn’t notice it was