Get events from database
-
Hello Developer,
I have two running wp site in a same database and in one of them I’ve setup your event plugin.I’ve added the code below to get the same events on other site pulling out directly from the database, so I add events just one time.
I would like to ask you how can i add the start date on the event and how i have to improve the sql code.
When I’ve added the StartDate value from the table eo_events i get duplicated results.
For example, every dates is present, it’s attacched for every single event.I know it’s a bit tricky but I hope you can help me.
Thanks a lot$mydb = new wpdb('user','pass','database','host'); $events = $mydb->get_results("SELECT post_title, post_name, StartDate FROM wp_posts, eo_events WHERE post_type = 'event'"); foreach ($events as $obj) : ?> <div id="<?php echo $obj->post_id; ?>" class="fusion-one-third one_third fusion-layout-column fusion-column spacing-yes post"> <div class="fusion-date-and-formats"> <div class="fusion-date-box updated"> <span class="fusion-date"> <?php echo date('j', strtotime($obj->StartDate)); ?></span> <span class="fusion-month-year"> <?php setlocale(LC_ALL, 'it_IT'); echo strftime('%b %Y', strtotime($obj->StartDate)); ?></span> </div> <div class="fusion-format-box"><i class="fa fa-calendar"></i></div> </div> <div class="fusion-post-content post-content"> <h2 class="entry-title"> <a target="_blank" href="<?php echo $obj->post_name; ?>"><?php echo $obj->post_title; ?></a> </h2> </div> </div> <? endforeach; ?>
screenshot:
currently I’ve just six events, look how many i get ??
[IMG]https://i57.tinypic.com/209fz8g.png[/IMG]
screenshot
- The topic ‘Get events from database’ is closed to new replies.