Support

Home Forums Event Espresso Premium Create Instructor Column Events Table Template/People Admin

Create Instructor Column Events Table Template/People Admin

Posted: January 8, 2021 at 3:21 pm


dave Segal

January 8, 2021 at 3:21 pm

Hi there,

Could someone please advise?

I have read a few forum responses to this but all seem to have different info.
I’d like to add one column “Instructor” which has ID Type “27”
I have the espresso-events-table-template.template.php file open and save in child theme.

Thanks
Dave


Josh

  • Support Staff

January 8, 2021 at 5:03 pm

Hi Dave,

To add a column to an HTML table you’ll need to add one table heading item and one new cell to the table row. This requires modifying your custom espresso-events-table-template.template.php file.

To add the table heading item, you’ll add something like this with the other <th> markup:
<th class="th-group">Instructor</th>

Then, to get the data to display in the column cell, you’ll add this within the loop:
$people = EEM_Person::instance()->get_people_for_event_and_type($event_id = $post->ID, $people_type_id = 27);

This will create an array of objects that you can take the information from and display in your custom table. Within the table row, you can add a new cell to display the Instructor name for each event.
For example:

<td><?php
 foreach($people as $instructor) {
  if($instructor instanceof EE_Person){
   echo '<i>' . $instructor->name() . '</i>';
  }
 }
?>
</td>

The support post ‘Create Instructor Column Events Table Template/People Admin’ 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