Quantcast
Channel: Topic Tag: MySQL | WordPress.org
Viewing all articles
Browse latest Browse all 5527

Susa38 on "[Plugin: All-in-One Event Calendar] Custom MySQL query?"

$
0
0

Sorry but i'm working it on local mode
But this is the way:

I create a file named ai1ec-sample-usage.php
and I insert it on my theme folder

on this file I insert this code:

<?php
// inicio funcion eventos en home
function ai1ec2_display_events_func( $atts ) {
	global $ai1ec_registry;
	$content         = '<div id="content2"><img src="/wp-content/themes/scio/images/events-header.png" alt="" />';
	$time            = $ai1ec_registry->get( 'date.system' );
	// Get localized time
	$timestamp       = $time->current_time();
	// Set $limit to the specified categories/tags
	$limit           = array(
		//
		// this is demo data - please use your own filters
		//
		'tag_ids' => array (2368)
	);
	$events_per_page = 10;
	$paged           = 0;
	$event_results   = $ai1ec_registry->get( 'model.search' )
		->get_events_relative_to(
			$timestamp,
			$events_per_page,
			$paged,
			$limit
		);
	$dates = $ai1ec_registry->get(
			'view.calendar.view.agenda',
			$ai1ec_registry->get( 'http.request.parser' )
		)->get_agenda_like_date_array( $event_results['events'] );
	foreach ( $dates as $date ) {
		foreach ( $date['events']['allday'] as $instance ) {
			$post_title   = $instance->get( 'post' )->post_title;
			$post_name    = $instance->get( 'post' )->post_name;
			$instance_id  = $instance->get( 'instance_id' );
			$content     .= '<div class="hp-event">
				<a href="ai1ec_event/'.$post_name.'/?instance_id='.$instance_id.'">'
				.$post_title.'</a><br /><a class="read-more-link"  href="ai1ec_event/'.$post_name.'/?instance_id='.$instance_id.'">read more</a>
			</div>';
		}
		foreach ( $date['events']['notallday'] as $instance ) {
				$post_title   = $instance->get( 'post' )->post_title;
				$post_name    = $instance->get( 'post' )->post_name;
				$instance_id  = $instance->get( 'instance_id' );
				$content     .= '<div class="hp-event">
					<a href="ai1ec_event/'.$post_name.'/?instance_id='.$instance_id.'">'
					.$post_title.'</a><br /><a class="read-more-link"  href="ai1ec_event/'.$post_name.'/?instance_id='.$instance_id.'">read more</a>
					</div>';
		}
	}
	$content .= '</div>';
	return $content;
}
add_shortcode( 'display_events2', 'ai1ec2_display_events_func' );
// fin funcion eventos en home
?>

after I create a page template on my theme and I use it to make on wordpress a page,

on the page template I insert

<div class"own-event">
           <?php include 'ai1ec-sample-usage.php'; ?>
            <?php
echo do_shortcode( '[display_events2]' );
?>
</div>

the on the fronend I can see the result:

this is one event title -Madrid-
read more
this the second event title -Madrid-
read more
this the 3 event title -Barcelona-
read more
this the 4 event title -Madrid-
read more
this the 5 event title -Barcelona-
read more

And I would like to show also the post_thumbnail


Viewing all articles
Browse latest Browse all 5527

Trending Articles