Below, you’ll find a detailed guide on how to add the My Calendar Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the My Calendar Plugin shortcodes not to show or not to work correctly.
Before starting, here is an overview of the My Calendar Plugin and the shortcodes it provides:
"My Calendar is a versatile WordPress plugin perfect for managing and displaying events. Its user-friendly interface makes scheduling simple and efficient."
- [my_calendar]
- [my_calendar_upcoming]
- [my_calendar_today]
- [my_calendar_locations]
- [my_calendar_categories]
- [my_calendar_access]
- [mc_filters]
- [my_calendar_show_locations]
- [my_calendar_event]
- [my_calendar_search]
- [my_calendar_now]
- [my_calendar_next]
My Calendar [my_calendar] Shortcode
The My Calendar shortcode is a powerful tool for creating customized calendar displays on your WordPress site. It allows you to specify parameters such as the calendar’s format, time frame, and categories to display. It also provides options for filtering by author, host, or specific dates. The shortcode can be tailored to show a specific language and can even adjust the display based on the current user’s ID. This flexibility makes it an invaluable asset for managing and presenting event information in a user-friendly manner.
Shortcode: [my_calendar]
Parameters
Here is a list of all possible my_calendar shortcode parameters and attributes:
name
– Specifies the name of the calendar to be displayedformat
– Determines the layout of the calendar (e.g. ‘calendar’, ‘mini’)category
– Sets the category of events to be showntime
– Sets the period of time for events to be shown (e.g. ‘month’)ltype
– Location type for filtering eventslvalue
– Specific value for the location typeauthor
– Filters events based on the authorhost
– Filters events based on the hostid
– Unique identifier of the calendartemplate
– Template for the display of the calendarabove
– Content to display above the calendarbelow
– Content to display below the calendaryear
– Specifies a specific year for the calendarmonth
– Specifies a specific month for the calendarday
– Specifies a specific day for the calendarsite
– Filters events based on the sitemonths
– Specifies the number of months to displaysearch
– Search term for filtering eventsself
– Filters events based on the current userlanguage
– Specifies the language for the calendarweekends
– Toggles the display of weekends on the calendar
Examples and Usage
Basic example – Displaying the calendar using the ‘my_calendar’ shortcode without any parameters will show the calendar with all events.
[my_calendar]
Advanced examples
Displaying a calendar for a specific category of events. In this example, we’re showing a calendar that only includes events from the ‘workshop’ category.
[my_calendar category="workshop"]
Displaying a calendar in a specific format and time. In this example, we’re showing a ‘list’ format calendar that displays events for the ‘week’.
[my_calendar format="list" time="week"]
Displaying a calendar that only includes events from a specific author. In this example, we’re showing a calendar that only includes events from the author with the ID of 1.
[my_calendar author="1"]
Using the shortcode to display a calendar by referencing both format and category. The calendar will first try to load by format, but if not found, it will try to load by category.
[my_calendar format="list" category="workshop"]
PHP Function Code
In case you have difficulties debugging what causing issues with [my_calendar]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'my_calendar', 'my_calendar_insert' );
Shortcode PHP function:
function my_calendar_insert( $atts, $content = null ) {
$args = shortcode_atts(
array(
'name' => 'all',
'format' => 'calendar',
'category' => 'all',
'time' => 'month',
'ltype' => '',
'lvalue' => '',
'author' => 'all',
'host' => 'all',
'id' => '',
'template' => '',
'above' => '',
'below' => '',
'year' => false,
'month' => false,
'day' => false,
'site' => false,
'months' => false,
'search' => '',
'self' => '',
'language' => '',
'weekends' => mc_get_option( 'show_weekends' ),
),
$atts,
'my_calendar'
);
if ( (int) get_the_ID() === (int) mc_get_option( 'uri_id' ) ) {
$params = get_post_meta( get_the_ID(), '_mc_calendar', true );
$params = ( is_array( $params ) ) ? $params : array();
$args = array_merge( $args, $params );
}
if ( 'mini' !== $args['format'] ) {
if ( isset( $_GET['format'] ) ) {
$args['format'] = sanitize_text_field( $_GET['format'] );
}
}
if ( isset( $_GET['search'] ) ) {
$args['search'] = sanitize_text_field( $_GET['search'] );
}
global $user_ID;
if ( 'current' === $args['author'] ) {
/**
* Filter the author parameter for a My Calendar view if set as 'current'. Default current user ID.
*
* @hook mc_display_author
*
* @param {int} $user_ID Logged-in user ID.
* @param {string} $context 'main' to indicate the `my_calendar` shortcode is running.
*
* @return {int} Valid author ID.
*/
$args['author'] = apply_filters( 'mc_display_author', $user_ID, 'main' );
}
if ( 'current' === $args['host'] ) {
/**
* Filter the host parameter for a My Calendar view if set as 'current'. Default current user ID.
*
* @hook mc_display_host
*
* @param {int} $user_ID Logged-in user ID.
* @param {string} $context 'main' to indicate the `my_calendar` shortcode is running.
*
* @return {int} Valid author ID.
*/
$args['host'] = apply_filters( 'mc_display_host', $user_ID, 'main' );
}
return my_calendar( $args );
}
Code file location:
my-calendar/my-calendar/my-calendar.php
My Calendar [my_calendar_upcoming] Shortcode
The My Calendar plugin shortcode, ‘my_calendar_upcoming’, is designed to display upcoming events. It offers a customizable array of features, allowing users to modify the display based on their preferences. The shortcode’s PHP function, ‘my_calendar_insert_upcoming’, provides a set of attributes, like ‘before’, ‘after’, ‘type’, ‘category’, and more. These attributes can be customized to filter and order the events. For instance, the ‘author’ and ‘host’ parameters can be set to ‘current’ to display events related to the current user. Also, users can define the language, event period (‘from’ and ‘to’), and site to further refine the event’s display. In summary, the ‘my_calendar_upcoming’ shortcode offers a flexible way to display upcoming events on your WordPress site.
Shortcode: [my_calendar_upcoming]
Parameters
Here is a list of all possible my_calendar_upcoming shortcode parameters and attributes:
before
– set the timeframe before the upcoming eventsafter
– set the timeframe after the upcoming eventstype
– specifies the type of events to displaycategory
– filters the events by categorytemplate
– specifies the template to use for displayfallback
– message to display if no events are foundorder
– sets the order of events, ascending or descendingskip
– number of events to skip in the listshow_today
– determines if today’s events should be includedshow_recurring
– determines if recurring events should be displayedauthor
– filters events by the authorhost
– filters events by the hostltype
– filters events by location typelvalue
– filters events by location valuefrom
– sets the start date for displaying eventsto
– sets the end date for displaying eventssite
– filters events by websitelanguage
– filters events by language
Examples and Usage
Basic example – To display upcoming events using the My Calendar plugin, you can utilize the ‘my_calendar_upcoming’ shortcode. The default settings will be applied if no additional parameters are specified.
[my_calendar_upcoming /]
Advanced examples
Display upcoming events in a specific category. In this example, the ‘category’ parameter is set to ‘music’, which means only upcoming events in the ‘music’ category will be shown.
[my_calendar_upcoming category='music' /]
Show upcoming events ordered in descending order. The ‘order’ parameter is set to ‘desc’, which means the events closest to the current date will be displayed first.
[my_calendar_upcoming order='desc' /]
Display upcoming events, skipping the first one. The ‘skip’ parameter is set to ‘1’, which means the first upcoming event will not be displayed.
[my_calendar_upcoming skip='1' /]
Show upcoming events from a specific author only. The ‘author’ parameter is set to ‘5’, which means only events created by the author with the user ID of 5 will be displayed.
[my_calendar_upcoming author='5' /]
These are just a few examples of how the ‘my_calendar_upcoming’ shortcode can be used with various parameters to customize the display of upcoming events on your WordPress site.
PHP Function Code
In case you have difficulties debugging what causing issues with [my_calendar_upcoming]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'my_calendar_upcoming', 'my_calendar_insert_upcoming' );
Shortcode PHP function:
function my_calendar_insert_upcoming( $atts ) {
$args = shortcode_atts(
array(
'before' => 'default',
'after' => 'default',
'type' => 'default',
'category' => 'default',
'template' => 'default',
'fallback' => '',
'order' => 'asc',
'skip' => '0',
'show_today' => 'yes',
'show_recurring' => 'yes',
'author' => 'default',
'host' => 'default',
'ltype' => '',
'lvalue' => '',
'from' => false,
'to' => false,
'site' => false,
'language' => '',
),
$atts,
'my_calendar_upcoming'
);
global $user_ID;
if ( 'current' === $args['author'] ) {
/**
* Filter the author parameter for a My Calendar view if set as 'current'. Default current user ID.
*
* @hook mc_display_author
*
* @param {int} $user_ID Logged-in user ID.
* @param {string} $context 'upcoming' to indicate the `my_calendar_upcoming` shortcode is running.
*
* @return {int} Valid author ID.
*/
$args['author'] = apply_filters( 'mc_display_author', $user_ID, 'upcoming' );
}
if ( 'current' === $args['host'] ) {
/**
* Filter the host parameter for a My Calendar view if set as 'current'. Default current user ID.
*
* @hook mc_display_host
*
* @param {int} $user_ID Logged-in user ID.
* @param {string} $context 'upcoming' to indicate the `my_calendar_upcoming` shortcode is running.
*
* @return {int} Valid author ID.
*/
$args['host'] = apply_filters( 'mc_display_host', $user_ID, 'upcoming' );
}
return my_calendar_upcoming_events( $args );
}
Code file location:
my-calendar/my-calendar/my-calendar.php
My Calendar [my_calendar_today] Shortcode
The My Calendar plugin shortcode is used to display today’s events. It allows customization based on category, author, host, template, fallback, date, site, and language. It checks if ‘author’ or ‘host’ is set to ‘current’ and applies filters to use the current user ID. The function ‘my_calendar_todays_events’ is then called with these arguments.
Shortcode: [my_calendar_today]
Parameters
Here is a list of all possible my_calendar_today shortcode parameters and attributes:
category
– specifies the category of the calendar eventsauthor
– sets the author of the calendar eventshost
– designates the host of the calendar eventstemplate
– defines the template to display the eventsfallback
– provides alternative content if no events existdate
– if set, displays events for a specific datesite
– if set, shows events from a specific sitelanguage
– sets the language for the displayed events
Examples and Usage
Basic example – Display today’s events from the default category, author, and host
[my_calendar_today /]
Advanced examples
Display today’s events from a specific category, default author, and default host:
[my_calendar_today category="music" /]
Display today’s events from the default category, a specific author, and default host:
[my_calendar_today author="John Doe" /]
Display today’s events from the default category, default author, and a specific host:
[my_calendar_today host="Event Venue" /]
Display today’s events from a specific category, author, and host:
[my_calendar_today category="music" author="John Doe" host="Event Venue" /]
Display today’s events from a specific category, author, and host with a fallback message if no events are found:
[my_calendar_today category="music" author="John Doe" host="Event Venue" fallback="No events found for today." /]
Display today’s events from a specific category, author, and host in a specific language:
[my_calendar_today category="music" author="John Doe" host="Event Venue" language="en" /]
PHP Function Code
In case you have difficulties debugging what causing issues with [my_calendar_today]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'my_calendar_today', 'my_calendar_insert_today' );
Shortcode PHP function:
function my_calendar_insert_today( $atts ) {
$args = shortcode_atts(
array(
'category' => 'default',
'author' => 'default',
'host' => 'default',
'template' => 'default',
'fallback' => '',
'date' => false,
'site' => false,
'language' => '',
),
$atts,
'my_calendar_today'
);
global $user_ID;
if ( 'current' === $args['author'] ) {
/**
* Filter the author parameter for a My Calendar view if set as 'current'. Default current user ID.
*
* @hook mc_display_author
*
* @param {int} $user_ID Logged-in user ID.
* @param {string} $context 'today' to indicate the `my_calendar_today` shortcode is running.
*
* @return {int} Valid author ID.
*/
$args['author'] = apply_filters( 'mc_display_author', $user_ID, 'today' );
}
if ( 'current' === $args['host'] ) {
/**
* Filter the host parameter for a My Calendar view if set as 'current'. Default current user ID.
*
* @hook mc_display_host
*
* @param {int} $user_ID Logged-in user ID.
* @param {string} $context 'today' to indicate the `my_calendar_today` shortcode is running.
*
* @return {int} Valid author ID.
*/
$args['host'] = apply_filters( 'mc_display_host', $user_ID, 'today' );
}
return my_calendar_todays_events( $args );
}
Code file location:
my-calendar/my-calendar/my-calendar.php
My Calendar [my_calendar_locations] Shortcode
The ‘my_calendar_locations’ shortcode is part of the My Calendar plugin. It displays a list of calendar event locations. It allows customization such as the type of data to display and the target URL.
Shortcode: [my_calendar_locations]
Parameters
Here is a list of all possible my_calendar_locations shortcode parameters and attributes:
show
– defines the display format of the locations, default is ‘list’datatype
– determines type of data to display, typically ‘name’target_url
– sets URL to redirect to when a location is clicked
Examples and Usage
Basic example – Displays a list of locations from the My Calendar plugin using the default parameters.
[my_calendar_locations]
Advanced examples
Displays a list of locations from the My Calendar plugin, specifying the ‘show’ parameter as ‘grid’ and the ‘datatype’ parameter as ‘description’. This will present the locations in a grid format and include the description of each location.
[my_calendar_locations show="grid" datatype="description"]
Another advanced usage of the shortcode involves specifying a target URL. This can be useful if you want the locations to link to a specific page. In this example, the ‘target_url’ parameter is set to ‘http://example.com’.
[my_calendar_locations target_url="http://example.com"]
Finally, a more complex example involves using all three parameters. This will display the locations in a grid format, include the description of each location, and link each location to the specified URL.
[my_calendar_locations show="grid" datatype="description" target_url="http://example.com"]
PHP Function Code
In case you have difficulties debugging what causing issues with [my_calendar_locations]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'my_calendar_locations', 'my_calendar_locations' );
Shortcode PHP function:
function my_calendar_locations( $atts ) {
$args = shortcode_atts(
array(
'show' => 'list',
'datatype' => 'name',
'target_url' => '',
),
$atts,
'my_calendar_locations'
);
return my_calendar_locations_list( $args['show'], $args['datatype'], 'single', $args['target_url'] );
}
Code file location:
my-calendar/my-calendar/my-calendar.php
My Calendar [my_calendar_categories] Shortcode
The ‘my_calendar_categories’ shortcode from the My-Calendar plugin displays a list of calendar categories. It uses two parameters: ‘show’ and ‘target_url’. ‘Show’ determines the display style (default is ‘list’) and ‘target_url’ specifies the link for each category.
Shortcode: [my_calendar_categories]
Parameters
Here is a list of all possible my_calendar_categories shortcode parameters and attributes:
show
– determines the display format of the categoriestarget_url
– defines the URL where the categories will link to
Examples and Usage
Basic example – Display a list of My Calendar categories.
[my_calendar_categories show="list" /]
Advanced examples
Display a list of My Calendar categories and specify a target URL for the categories.
[my_calendar_categories show="list" target_url="http://example.com" /]
Display a single My Calendar category and specify a target URL for the category.
[my_calendar_categories show="single" target_url="http://example.com" /]
Display a public My Calendar category.
[my_calendar_categories show="public" /]
PHP Function Code
In case you have difficulties debugging what causing issues with [my_calendar_categories]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'my_calendar_categories', 'my_calendar_categories' );
Shortcode PHP function:
function my_calendar_categories( $atts ) {
$args = shortcode_atts(
array(
'show' => 'list',
'target_url' => '',
),
$atts,
'my_calendar_categories'
);
return my_calendar_categories_list( $args['show'], 'public', 'single', $args['target_url'] );
}
Code file location:
my-calendar/my-calendar/my-calendar.php
My Calendar [my_calendar_access] Shortcode
The My Calendar plugin shortcode, ‘my_calendar_access’, provides a list or single view of calendar events. It allows customization of the display view and target URL for event details.
Shortcode: [my_calendar_access]
Parameters
Here is a list of all possible my_calendar_access shortcode parameters and attributes:
show
– defines the display style of the calendar, default is ‘list’target_url
– sets the URL where calendar events link to
Examples and Usage
Basic example – A simple usage of the ‘my_calendar_access’ shortcode to display the access list in its default ‘list’ view.
[my_calendar_access]
Advanced examples
Alter the display of the access list to a ‘single’ view by using the ‘show’ parameter.
[my_calendar_access show="single"]
Define a custom target URL for the access list items using the ‘target_url’ parameter. In this example, the target URL is set to ‘https://example.com’.
[my_calendar_access target_url="https://example.com"]
Combine multiple parameters to customize the display of the access list. In this example, the access list is displayed in a ‘single’ view and each item links to ‘https://example.com’.
[my_calendar_access show="single" target_url="https://example.com"]
PHP Function Code
In case you have difficulties debugging what causing issues with [my_calendar_access]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'my_calendar_access', 'my_calendar_access' );
Shortcode PHP function:
function my_calendar_access( $atts ) {
$args = shortcode_atts(
array(
'show' => 'list',
'target_url' => '',
),
$atts,
'my_calendar_access'
);
return mc_access_list( $args['show'], 'single', $args['target_url'] );
}
Code file location:
my-calendar/my-calendar/my-calendar.php
My Calendar [mc_filters] Shortcode
The My Calendar plugin shortcode ‘mc_filters’ is designed to display specific calendar filters. The ‘mc_filters’ shortcode allows you to control the visibility of categories and locations on your calendar. You can specify the filters to show and the target URL for the filters. It also allows you to define the location type as ‘name’.
Shortcode: [mc_filters]
Parameters
Here is a list of all possible mc_filters shortcode parameters and attributes:
show
– Determines what to display, either ‘categories’ or ‘locations’.target_url
– URL where filtered results will be shown.ltype
– Defines location type, ‘name’ by default.
Examples and Usage
Basic example – The shortcode displays the calendar filters based on the categories and locations. It does not specify a target URL or location type, so it uses the default values.
[mc_filters show="categories,locations" /]
Advanced examples
Using the shortcode to display the calendar filters based on categories only. The target URL is specified, which means the filters will redirect to this URL. The location type is set to ‘name’, meaning the location names will be displayed in the filters.
[mc_filters show="categories" target_url="http://example.com/events" ltype="name" /]
Using the shortcode to display the calendar filters based on locations only. The target URL is not specified, so it uses the default value. The location type is set to ‘name’, meaning the location names will be displayed in the filters.
[mc_filters show="locations" ltype="name" /]
Using the shortcode to display the calendar filters based on both categories and locations. A specific target URL is set, and the location type is set to ‘name’. This means the filters will redirect to the specified URL and display location names.
[mc_filters show="categories,locations" target_url="http://example.com/events" ltype="name" /]
PHP Function Code
In case you have difficulties debugging what causing issues with [mc_filters]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'mc_filters', 'my_calendar_filters' );
Shortcode PHP function:
function my_calendar_filters( $atts ) {
$args = shortcode_atts(
array(
'show' => 'categories,locations',
'target_url' => '',
'ltype' => 'name',
),
$atts,
'my_calendar_filters'
);
return mc_filters( $args['show'], $args['target_url'], $args['ltype'] );
}
Code file location:
my-calendar/my-calendar/my-calendar.php
My Calendar [my_calendar_show_locations] Shortcode
The My Calendar plugin shortcode is designed to display a list of event locations. This shortcode allows users to customize the data type, sort order, and template of the locations list. It uses the ‘my_calendar_show_locations’ function to return the sorted locations list.
Shortcode: [my_calendar_show_locations]
Parameters
Here is a list of all possible my_calendar_show_locations shortcode parameters and attributes:
datatype
– Defines the type of data to be displayedsort
– Specifies the order in which data is displayedtemplate
– Sets the design template for the displayed data
Examples and Usage
Basic example – The basic usage of the shortcode displays the locations list by name.
[my_calendar_show_locations /]
Advanced examples
Displaying the locations list sorted by a specific parameter. In this case, the locations are sorted by ‘city’.
[my_calendar_show_locations sort='city' /]
Using a custom template for the locations list. The template file should be located in your theme’s directory.
[my_calendar_show_locations template='my_custom_template' /]
Combining multiple parameters. This example displays the locations list sorted by ‘city’ and uses a custom template.
[my_calendar_show_locations sort='city' template='my_custom_template' /]
PHP Function Code
In case you have difficulties debugging what causing issues with [my_calendar_show_locations]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'my_calendar_show_locations', 'my_calendar_show_locations_list' );
Shortcode PHP function:
function my_calendar_show_locations_list( $atts ) {
$args = shortcode_atts(
array(
'datatype' => 'name',
'sort' => '',
'template' => '',
),
$atts,
'my_calendar_locations_list'
);
// Sort replaces 'datatype'.
$sort = ( '' !== $args['sort'] ) ? $args['sort'] : $args['datatype'];
return my_calendar_show_locations( $sort, $args['template'] );
}
Code file location:
my-calendar/my-calendar/my-calendar.php
My Calendar [my_calendar_event] Shortcode
The My Calendar plugin shortcode, ‘my_calendar_event’, displays a specific event. It uses parameters like ‘event’, ‘template’, ‘list’, ‘before’, ‘after’, and ‘instance’ to customize the event’s display.
Shortcode: [my_calendar_event]
Parameters
Here is a list of all possible my_calendar_event shortcode parameters and attributes:
event
– Defines the specific event to be displayed.template
– Determines the format of the event details.list
– Specifies the layout of the event list.before
– Sets the markup to be added before the event list.after
– Sets the markup to be added after the event list.instance
– Controls whether the event list should be unique or not.
Examples and Usage
Basic example – Show a single event with its title and description using the ‘my_calendar_event’ shortcode.
[my_calendar_event event='1' /]
With the above shortcode, you can display the event with an ID of 1. The event’s title will be displayed in an H3 tag, and the event’s description will be displayed below the title.
Advanced examples
You can customize the event display by changing the ‘template’ attribute. Here is an example where the event’s title is displayed in an H2 tag, and the event’s description is displayed in a paragraph tag:
[my_calendar_event event='1' template='{title}
{description}
' /]
Additionally, you can display a list of event instances using the ‘list’ attribute. In this example, each instance is displayed as a list item with the date and time of the event:
[my_calendar_event event='1' list='{date}, {time} ' /]
Lastly, you can wrap the list of event instances in custom HTML using the ‘before’ and ‘after’ attributes. In this example, the list of event instances is wrapped in a div with a class of ‘my-event-list’:
[my_calendar_event event='1' list='{date}, {time} ' before='' after='' /]
These examples demonstrate the versatility of the ‘my_calendar_event’ shortcode, allowing you to display event information in a variety of ways to best suit your website’s design and your audience’s needs.
PHP Function Code
In case you have difficulties debugging what causing issues with [my_calendar_event]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'my_calendar_event', 'my_calendar_show_event' );
Shortcode PHP function:
function my_calendar_show_event( $atts ) {
$args = shortcode_atts(
array(
'event' => '',
'template' => '<h3>{title}</h3>{description}',
'list' => '<li>{date}, {time}</li>',
'before' => '<ul>',
'after' => '</ul>',
'instance' => false,
),
$atts,
'my_calendar_event'
);
return mc_instance_list( $args );
}
Code file location:
my-calendar/my-calendar/my-calendar.php
My Calendar [my_calendar_search] Shortcode
The My Calendar plugin shortcode, ‘my_calendar_search’, enables a search function within your calendar. It allows users to search for specific events. This shortcode comes with two parameters: ‘type’ and ‘url’. The ‘type’ parameter defines the search form style, defaulted to ‘simple’. The ‘url’ parameter is for the form action URL.
Shortcode: [my_calendar_search]
Parameters
Here is a list of all possible my_calendar_search shortcode parameters and attributes:
type
– Defines the format of the search formurl
– Specifies the location to send search queries
Examples and Usage
Basic example – A basic representation of the my_calendar_search shortcode without any additional parameters. This will display a simple search form for the My Calendar plugin.
[my_calendar_search]
Advanced examples
Modifying the search form type through the ‘type’ parameter. In this example, the ‘type’ parameter is set to ‘advanced’, which changes the search form to an advanced search form.
[my_calendar_search type="advanced"]
Specifying a custom URL for the search form to post to using the ‘url’ parameter. This example sets the ‘url’ parameter to ‘https://www.example.com/search-results’, which means the search form will post to this URL.
[my_calendar_search url="https://www.example.com/search-results"]
Combining both ‘type’ and ‘url’ parameters. This example displays an advanced search form that posts to a custom URL.
[my_calendar_search type="advanced" url="https://www.example.com/search-results"]
PHP Function Code
In case you have difficulties debugging what causing issues with [my_calendar_search]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'my_calendar_search', 'my_calendar_search' );
Shortcode PHP function:
function my_calendar_search( $atts ) {
$args = shortcode_atts(
array(
'type' => 'simple',
'url' => '',
),
$atts,
'my_calendar_search'
);
return my_calendar_searchform( $args['type'], $args['url'] );
}
Code file location:
my-calendar/my-calendar/my-calendar.php
My Calendar [my_calendar_now] Shortcode
The My Calendar plugin shortcode, ‘my_calendar_now’, displays current events from specified categories. It allows customization of event details shown using templates. This shortcode can be modified with parameters like ‘category’ for filtering events, ‘template’ for display format, and ‘site’ for multisite usage.
Shortcode: [my_calendar_now]
Parameters
Here is a list of all possible my_calendar_now shortcode parameters and attributes:
category
– Specifies the category of events to display.template
– Defines how the event details are formatted.site
– Determines whether to show events from all sites in a multisite network.
Examples and Usage
Basic example – Utilizes the my_calendar_now shortcode to display events from all categories. The event title is highlighted, followed by the time range.
[my_calendar_now]
Advanced examples
Displaying events from a specific category. In this example, we are using the shortcode to display events from the category with the ID ‘5’. The event title is highlighted, followed by the time range.
[my_calendar_now category='5']
Customizing the template of the displayed events. In this example, the event title is displayed first, followed by the time range, and then the category. The shortcode also specifies that the events should be fetched from the site with the ID ‘2’.
[my_calendar_now template='{link_title} {timerange} {category}' site='2']
Combining both the category and site parameters. In this example, the shortcode is used to display events from the category with the ID ‘3’, and the events are fetched from the site with the ID ‘1’. The event title is highlighted, followed by the time range.
[my_calendar_now category='3' site='1']
PHP Function Code
In case you have difficulties debugging what causing issues with [my_calendar_now]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'my_calendar_now', 'my_calendar_now' );
Shortcode PHP function:
function my_calendar_now( $atts ) {
$args = shortcode_atts(
array(
'category' => '',
'template' => '<strong>{link_title}</strong> {timerange}',
'site' => false,
),
$atts,
'my_calendar_now'
);
return my_calendar_events_now( $args['category'], $args['template'], $args['site'] );
}
Code file location:
my-calendar/my-calendar/my-calendar.php
My Calendar [my_calendar_next] Shortcode
The My Calendar plugin shortcode ‘my_calendar_next’ is used to display upcoming events. This shortcode fetches the next event from a specified category. It allows customization of the output format through the ‘template’ attribute. It also supports skipping a certain number of events and multi-site use.
Shortcode: [my_calendar_next]
Parameters
Here is a list of all possible my_calendar_next shortcode parameters and attributes:
category
– Specifies the category of the event to display next.template
– Defines the layout and style of the displayed event.skip
– Number of events to skip before displaying the next one.site
– If set to true, displays events from all network sites.
Examples and Usage
Basic example – Displays the next event from the calendar without any specific category or template.
[my_calendar_next /]
Advanced examples
Displaying the next event from a specific category, in this case, the category is ‘music’. The template is also customized to show the event title in bold and the time range.
[my_calendar_next category='music' template='{link_title} {timerange}' /]
Skipping the next event and displaying the event after that. This is done by setting the ‘skip’ parameter to 1. The ‘site’ parameter is also set to true, which means the event is fetched from the entire network in a multisite setup.
[my_calendar_next skip=1 site=true /]
Combining all parameters to display the next event from a specific category, with a customized template, skipping the next event, and fetching the event from the entire network in a multisite setup.
[my_calendar_next category='music' template='{link_title} {timerange}' skip=1 site=true /]
PHP Function Code
In case you have difficulties debugging what causing issues with [my_calendar_next]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'my_calendar_next', 'my_calendar_next' );
Shortcode PHP function:
function my_calendar_next( $atts ) {
$args = shortcode_atts(
array(
'category' => '',
'template' => '<strong>{link_title}</strong> {timerange}',
'skip' => 0,
'site' => false,
),
$atts,
'my_calendar_next'
);
return my_calendar_events_next( $args['category'], $args['template'], $args['skip'], $args['site'] );
}
Code file location:
my-calendar/my-calendar/my-calendar.php
Conclusion
Now that you’ve learned how to embed the My Calendar Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.
Leave a Reply