Timetable and Event Schedule by MotoPress Shortcode

Below, you’ll find a detailed guide on how to add the Timetable and Event Schedule by MotoPress Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Timetable and Event Schedule by MotoPress Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Timetable and Event Schedule by MotoPress Plugin and the shortcodes it provides:

Plugin Icon
Timetable and Event Schedule by MotoPress

"Timetable and Event Schedule by MotoPress is a dynamic plugin designed for creating and managing timetables for events on your WordPress site with utmost ease."

★★★★✩ (61) Active Installs: 30000+ Tested with: 6.2.3 PHP Version: false
Included Shortcodes:
  • [mp-timetable]

Timetable and Event Schedule by MotoPress [mp-timetable] Shortcode

The mp-timetable shortcode is a powerful tool in WordPress that allows users to create and display a dynamic event timetable. This shortcode accepts various parameters to customize the timetable’s appearance and functionality. It includes options for event categories, column display, view type, sorting, labels, and more. The shortcode also enables users to control the visual aspects like text alignment, row height, and font size. Moreover, it has options for hiding specific elements, making it highly adaptable to different use cases. The shortcode ensures a responsive design, making the timetable mobile-friendly. In case of no events or columns, it returns an ’empty-search-events’ template, otherwise, it displays the ‘index-timetable’ template.

Shortcode: [mp-timetable]

Parameters

Here is a list of all possible mp-timetable shortcode parameters and attributes:

  • events – Specifies the events to be displayed
  • event_categ – Filters events by category
  • col – Defines the number of columns
  • increment – Sets the increment value for time slots
  • view – Selects the display mode, dropdown list or tabs
  • view_sort – Sets the sorting order of the view
  • label – Sets the label for “All Events”
  • hide_label – Hides the label if set to “1”
  • title – Displays the event title if set to “1”
  • time – Shows the event time if set to “1”
  • group – Groups events if set to “1”
  • sub-title – Displays the event subtitle if set to “1”
  • description – Shows the event description if set to “1”
  • user – Displays the user if set to “1”
  • hide_hrs – Hides hours if set to “1”
  • hide_empty_rows – Hides empty rows if set to “1”
  • text_align_vertical – Aligns text vertically
  • row_height – Sets the row height
  • font_size – Sets the font size
  • disable_event_url – Disables the event URL if set to “1”
  • text_align – Sets the text alignment
  • id – Unique identifier of the timetable
  • custom_class – Allows for custom CSS classes
  • responsive – Makes the timetable responsive if set to “1”
  • table_layout – Sets the table layout

Examples and Usage

Basic example – A simple usage of the mp-timetable shortcode to display a timetable with default settings.

[mp-timetable]

For more advanced usage, the mp-timetable shortcode can accept various parameters to customize the timetable display. Here are some examples:

Advanced examples – Displaying a timetable with specific events, and setting the view to tabs instead of the default dropdown list.

[mp-timetable events="yoga, pilates" view="tabs"]

Setting the increment to 0.5, hiding the label, and setting the text alignment to right.

[mp-timetable increment="0.5" hide_label="1" text_align="right"]

Displaying a timetable with a custom class, disabling the event URL, and setting the table layout to fixed.

[mp-timetable custom_class="my_custom_class" disable_event_url="1" table_layout="fixed"]

These are just a few examples of how you can use the mp-timetable shortcode to customize your timetable display. You can mix and match these parameters to achieve the exact layout and functionality you need for your site.

PHP Function Code

In case you have difficulties debugging what causing issues with [mp-timetable] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'mp-timetable', array( $this, "show_shortcode" ) );

Shortcode PHP function:

function show_shortcode( $params ) {
		global $mptt_shortcode_data;

		$this->add_plugin_js( 'shortcode' );

		if ( empty( $params ) ) {
			$params = array();
		}

		$mptt_shortcode_data = array();

		$mptt_shortcode_data[ 'params' ] = $params = shortcode_atts( array(
			'events'              => "",
			'event_categ'         => "",
			'col'                 => "",
			'increment'           => "1", // 1 | 0.5 | 0.25
			'view'                => "dropdown_list", // dropdown_list | tabs
			'view_sort'           => "", // '' | menu_order || post_title
			'label'               => __( "All Events", 'mp-timetable' ),
			'hide_label'          => "0",
			'title'               => "0",
			'time'                => "0",
			'group'               => "0",
			'sub-title'           => "0",
			'description'         => "0",
			'user'                => "0",
			'hide_hrs'            => "0",
			'hide_empty_rows'     => "1",
			'text_align_vertical' => "default", // default | top | middle | bottom
			'row_height'          => "45",
			'font_size'           => "",
			'disable_event_url'   => "0",
			'text_align'          => "center", // left | center | right
			'id'                  => "",
			'custom_class'        => "",
			'responsive'          => "1",
			'table_layout'        => ""  // default | auto | fixed
		), $params );

		$mptt_shortcode_data[ 'events_data' ] = $this->get_shortcode_events( $params );
		
		if ( ! empty( $mptt_shortcode_data[ 'events_data' ] ) ) {
			if ( isset($mptt_shortcode_data[ 'events_data' ][ 'unique_events' ]) ) {
				$mptt_shortcode_data[ 'unique_events' ] = $mptt_shortcode_data[ 'events_data' ][ 'unique_events' ];
			}
			if ( isset( $mptt_shortcode_data[ 'events_data' ][ 'events' ] ) ) {
				unset( $mptt_shortcode_data[ 'events_data' ][ 'events' ] );
			}
		}
		
		if ( empty( $mptt_shortcode_data[ 'events_data' ][ 'events' ] ) && empty( $mptt_shortcode_data[ 'events_data' ][ 'column' ] ) ) {
			return $this->get_view()->get_template_html( 'shortcodes/empty-search-events', array() );
		} else {
			return $this->get_view()->get_template_html( 'shortcodes/index-timetable', array() );
		}
	}

Code file location:

mp-timetable/mp-timetable/classes/class-shortcode.php

Conclusion

Now that you’ve learned how to embed the Timetable and Event Schedule by MotoPress Plugin shortcode, 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.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *