Support

Home Forums Event Espresso Premium Counter of the number of the events in a category

Counter of the number of the events in a category

Posted: December 12, 2013 at 3:48 am


Ruech climb

December 12, 2013 at 3:48 am

Hi,
I have a list with pictures about a category on a page. Now I want that the users know how much events are in this category.

So I want something like a counter that shows me the number of the avtive avents in this category. Is this possible maybe with a shortcode or something else?

EE: v3.1.36.1.P
WP: v3.7.1

Thanks
Bernhard


Dean

December 12, 2013 at 5:03 am

Hi,

There isn’t a shortcode for it, but it could be done with one or two lines of code.

Edit the event_list.php file, around line 274 just after it says

<pre class=”brush: php; gutter: true; first-line: 1; highlight: []; html-script: false”>if ( $events) {

Below that add

<pre class=”brush: php; gutter: true; first-line: 1; highlight: []; html-script: false”>echo count($events);

This will simply add a number whihc corresponds with the number of events listed.

You could dress it up a bit like

<pre class=”brush: php; gutter: true; first-line: 1; highlight: []; html-script: false”>echo "<p>Number of Events found: " . count($events) . "</p>";


Ruech climb

December 12, 2013 at 6:06 am

Thanks for the answer. Sorry it´s not that what I´m searching for. Here is the link about my problem:

I have listed images that should describe a random category. You get to the category when u klick on the image-link. Now I want a counter description which gives the users a feedback of that how much active events are in this category…


Ruech climb

December 12, 2013 at 6:06 am

http://web341.server270.dns-was.de/kurse/


Sidney Harrell

December 13, 2013 at 9:17 am

Try:

You can add this code to one of the following:
1 – Your theme’s functions.php file. It may get overwritten the next time you update your theme.
2 – The EE custom files add-on in the custom_functions.php file.
3 – Use this blank plugin to hold the custom function.


Ruech climb

December 13, 2013 at 3:49 pm

Thanks a lot. Even though it doesn`t work 🙁
I added the code into my funtions.php (/includes/admin-files/) right after the line “<?php”. When I use this code on my site “[COUNT_EVENTS_IN_CATEGORY event_category_id=”02″]” nothing changes.

Example: http://web341.server270.dns-was.de/kurse/


Dean

December 16, 2013 at 12:46 am

Hi,

Wrong functions.php, it would need to go into the Themes functions.php file, not the one in Event Espresso.


Ruech climb

December 16, 2013 at 9:23 am

🙂 ok, now I’m a step further! Hopefully one last thing: It shows me an incorrect number of active events. It shows 6 instead of 3. I’ve deleted all events in the trash, pending, inactive… and deleted cache – without success. Do u have any solution for this?


Sidney Harrell

December 16, 2013 at 5:22 pm

For the category_id attribute in the shortcode, you’ll want to use the ‘Unique Category Identifier’ in the category editor. It should be the same as the one in the EVENT_ESPRESSO_CATEGORY shortcode that shows in the category’s row in the Manage Event Categories admin page.


Ruech climb

December 17, 2013 at 4:01 am

That’s the code that I used for it. I found out, that if I delete a event and then also deltete. In the trash, nothing changes in the number, that is shown. So there must be something wrong in the code or is there a way to delete events after the trash?


Sidney Harrell

December 17, 2013 at 5:36 pm

When the event is deleted, it must not be updating the category rel table. I’ve updated the gist above to take that into consideration.


Ruech climb

December 17, 2013 at 6:33 pm

That’s it, Thank you so much! 🙂

The support post ‘Counter of the number of the events in a category’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso