• This plugin doesn’t support a shortcode or a function to call manually, so you may find some troubles if you use more than one TheLoop on your page. I guess I’ll share with you what I’ve done to overcome this.

    Now before reading on, note that there’s already a topic here about using shortcode. When this method may work, it requires editing the plugin files, which is a big no-no.

    OK now this is how the calendar is being output (as of version 1.10.5):

    1. File app/controller/class-ai1ec-app-controller.php line 492:
    add_filter( 'the_content', array( &$this, 'append_content' ), PHP_INT_MAX - 1 );

    2. And at line 530:

    function append_content( $content )
    	{
    		// Enclose entire content (including any admin-provided page content) in
    		// the calendar container div
    		if( in_the_loop() )
    			$content =
    				'<div id="ai1ec-container" class="ai1ec-container timely">' .
    				$content . $this->page_content .
    				'</div>';
    
    		return $content;
    	}

    Basically, the plugin hooks into the_content() function and inject the calendar output there. With this approach, if you have multiple WP_Query on the page, the first the_content() call will have the calendar attached, which is not necessary what you may need.

    These steps can be done to “fix” this approach:

    1. Remove the filter, so that the calendar is not automatically populated. Put this into functions.php or at the beginning of your template:

    remove_filter('the_content', array(Ai1ec_App_Controller::get_instance(), 'append_content'), PHP_INT_MAX - 1);

    2. Manually store the calendar output into a string. Use this code for the first Loop on the page:

    if (have_posts()) {
    	the_post();
    	the_content();
    	$calendarContent = Ai1ec_App_Controller::get_instance()->append_content('');
    }

    3. Now we have the calendar string in a variable. A normal <?=$calendarContent?> can be used to output it anywhere.

    Hope this helps someone.

    https://www.ads-software.com/plugins/all-in-one-event-calendar/

Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Display the calendar manually’ is closed to new replies.