Home / Widgets / Combine shortcodes to have more than one month in Fullworks’ Event Manager
Duplicate Snippet

Embed Snippet on Your Site

Combine shortcodes to have more than one month in Fullworks’ Event Manager

This snippet combines 3 shortcodes of qem to list the current month, next month and the month after events.
It caters for no events found messaes and only displays if all three return no events.

To use this, enable the snippet and then use the shortcode [qem_3_months] as desired

You can customize this to any other shortcode options.

If you have subscrobed to the premium option of our Event Manager and need help customizing, please reach out to our support.

Code Preview
php
<?php
add_shortcode(
	'qem_3_months',
	function () {
		$out     = '';
		$display = \Quick_Event_Manager\Plugin\Core\Utilities::get_instance()->get_display_settings();
		$m0      = do_shortcode( '[qem id="current"]' );
		// get the next month numeral
		$next_month = gmdate( 'n', strtotime( '+1 month' ) );
		$m1         = do_shortcode( '[qem id=' . $next_month . ' ]' );
		// get the next month numeral
		$next_month = gmdate( 'n', strtotime( '+2 month' ) );
		$m2         = do_shortcode( '[qem id=' . $next_month . ' ]' );
		if ( '<h2>' . $display['noevent'] . '</h2>' === $m0 && '<h2>' . $display['noevent'] . '</h2>' === $m1 && '<h2>' . $display['noevent'] . '</h2>' === $m2 ) {
			$out = '<h2>' . $display['noevent'] . '</h2>';
		} else {
			if ( '<h2>' . $display['noevent'] . '</h2>' !== $m0 ) {
				$out .= $m1;
			}
			if ( '<h2>' . $display['noevent'] . '</h2>' !== $m1 ) {
				$out .= $m1;
			}
			if ( '<h2>' . $display['noevent'] . '</h2>' !== $m2 ) {
				$out .= $m2;
			}
		}
		return $out;
	}
);

Comments

Add a Comment