In this article, we will explain the process of overriding single event page.
MEC is created by developers for developers! And it’s highly developer-friendly so you can simply override MEC templates in your theme and make it compatible with your theme style or use MEC filters/actions to customize it.
Overriding Single Event Page
With the Overriding Modern Events Calendar Single Event Page feature, as a developer, you can easily adjust themes and customize your website in the best possible way.
MEC has a number of template files in /path/to/modern-events-calendar/templates/, you can simply override them in your theme or child theme.
For instance, place them on the /path/to/theme/single-mec-events.php or /path/to/child-theme/single-mec-events.php.
Note: If you use the lite version of MEC insert -lite after “modern-events-calendar”.Let’s learn how to build an exclusive Single Event Page for our events.
Creating a PHP file in the theme folder
First, create a PHP file in the root folder of your theme named single-mec-events.php.
Then, in coding, call the main WordPress functions of get_header and get_footer.
For example:
1 2 3 |
|
Now, you can place all your desired content between those 2 functions.
Supported PHP functions
Before getting any necessary fields for MEC, it is worth mentioning that the MEC plugin supports the main functions like getting titles, content, categories, tags, and featured images, however, loading other items needs to be done using the defined functions in
# | Name | Code |
01 | Title | get_the_title(); / the_title(); |
02 | Content | get_the_content(); / the_content(); |
03 | Thumbnail | the_post_thumbnail(); / the_post_thumbnail(‘full’); |
04 | Tag | get_the_tags(); |
05 | Label | get_terms( array(‘taxonomy’ => ‘mec_label’,’hide_empty’ => false,)); |
06 | Category | get_terms(array(‘taxonomy’ => ‘mec_category’,’hide_empty’ => false,)); |
07 | Event Color | get_post_meta( get_the_ID(), ‘mec_color’, true ); |
08 | Start Date | get_post_meta( get_the_ID(), ‘mec_start_date’, true ); |
09 | Start Hours | get_post_meta( get_the_ID(), ‘mec_start_time_hour’, true); |
10 | Start Minute | get_post_meta( get_the_ID(), ‘mec_start_time_minutes’, true); |
11 | Start AM/PM | get_post_meta( get_the_ID(), ‘mec_start_time_ampm’, true); |
12 | End Date | get_post_meta( get_the_ID(), ‘mec_end_date’, true ); |
13 | End Hours | get_post_meta( get_the_ID(), ‘mec_end_time_hour’, true); |
14 | End Minute | get_post_meta( get_the_ID(), ‘mec_end_time_minutes’, true); |
15 | End AM/PM | get_post_meta( get_the_ID(), ‘mec_end_time_ampm’, true); |
16 | MEC Comment | get_post_meta( get_the_ID(), ‘mec_comment’, true ); |
17 | Read More | get_post_meta( get_the_ID(), ‘mec_read_more’, true); |
18 | More Info | get_post_meta( get_the_ID(), ‘mec_more_info’, true); |
19 | Cost | get_post_meta( get_the_ID(), ‘mec_cost’, true ); |
20 | Event Excerpt | get_the_excerpt(); |
Modern Events Calendar Widgets
If you need to load the MEC’s widgets, please proceed as follows:
You should first add the following code in the PHP file “single-mec-events.php” you placed in the theme’s root directory.
1 2 3 |
|
Then call the widgets:
1 2 |
|
1 2 |
|
1 2 |
|
1 2 |
|
1 2 |
|
1 2 |
|
1 2 |
|
1 2 |
|
1 2 |
|
1 2 |
|
1 2 |
|
1 2 |
|
1 2
3 |
|
1 2 |
|
1 2 |
|
1 2
3 |
|
1 2 |
|
1 2 |
|
1 2 |
|
1 2 |
|
1 2 |
|
1 2 |
|
1 2 |
|