Support

Home Forums Event Espresso Premium category images in table view

category images in table view

Posted: October 8, 2015 at 8:20 am

Viewing 3 reply threads


Merlin

October 8, 2015 at 8:20 am

hi,

i’ve tried to add images to the events categories with this plugin: https://wordpress.org/plugins/categories-images/.

in the normal post and page categories i can see the plugin and the image upload but not in the events categories. do i have to put some code in something like event-category.php? And when it’s possible to add images, can you help me to integrate them into the table view template?

thanks in advance

merlin


Josh

  • Support Staff

October 8, 2015 at 11:35 am

Hi Merlin,

The plugin’s documentation that’s found here:

http://zahlan.net/blog/2012/06/categories-images/

says to use get_terms when looping for taxonomies. So in the documentation, where it has this:

get_terms('your_taxonomy')

you replace with this:

get_terms( 'espresso_event_categories' )


Merlin

October 9, 2015 at 1:27 am

Sorry, thats to high for me…and i know other plugins are not your business! but maybe a little more help please.

1. what i have to do to see the image selector in the event categories? which .php i have to edit? and what i have to paste in?

2. in my table-view php i have this
<td class="event_category event-<?php echo $post->ID; ?>"><?php espresso_event_categories(); ?></td>

but i only want to show the new images from the categories.


Josh

  • Support Staff

October 9, 2015 at 9:06 am

Please do not edit .php files. This is not only unnecessary, but your edits will break when you update to new versions.

1) You can select images for Event Espresso categories with the category plugin activated by going to this URL in your WP admin:

http://yoursite/wp-admin/edit-tags.php?taxonomy=espresso_event_categories

2) In the code you posted above, specifically where you use the espresso_event_categories() tag, that will return the names and links of the categories. To get the category image, you will need to use the template tag from the category images plugin documentation.

Along with that, you can follow and even add some code to the table template’s category loop that’s already there starting on line 76 of the table template. Do you see where it has the get_the_terms()? It’s right after that. You’ll want to be sure to initialize and reset before the loop and after the loop in the else that follows like this:

$category_image = '';

Then, inside the $event_categories loop, you can add something like this:

if ( function_exists( 'z_taxonomy_image_url' ) ) {
  $category_image = z_taxonomy_image_url( $term->term_id );
}

The function_exists check is optional, but probably a good idea in case the category image plugin ever gets deactivated.

Then, in the part of the template that outputs the row’s html, you add something like this:

<td><img src="<?php echo $category_image; ?>" /></td>

Viewing 3 reply threads

The support post ‘category images in table view’ 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