Display WordPress Event on Another Site with PHP in Iframe Banner
WordPress Event Management, Calendars & Registration › Forums › General Question › Display WordPress Event on Another Site with PHP in Iframe Banner
This topic contains 11 replies, has 3 voices, and was last updated by Tobias 7 years, 5 months ago.
-
AuthorPosts
-
December 13, 2016 at 11:35 am #25324
Hi, I would like make script for another sites to display event in specific venue (state or city) for specific date (from doday to next moth)
code removed
In this script I have problem to display “State” and sort the events for the current month…
can anyone help me?
- This topic was modified 8 years, 1 month ago by Stephen Harris.
Mario P.December 15, 2016 at 10:51 pm #25378Hi Mario,
Looks like some of your code got lost. The forums use markdown. The simplest way to post code would be to paste it in ‘as is’, highlight it all and click the curly braces.
As for obtaining the state in which the event occurs, you can do it as follows:
$venue_id = eo_get_venue(get_the_ID()); $address_details = eo_get_venue_address($venue_id); $state = $address_details['state'];
Stephen HarrisDecember 16, 2016 at 7:33 pm #25385Hi Stephen,
re post the code:
<?php require('wp-blog-header.php'); ?> <style> .caption {font-family: Verdana, sans-serif;font-size: 10px;float: left;margin: 0;padding: 0;position: relative;overflow: hidden;} .caption img {float: left;margin: 0;padding: 0;background: #fff;border: none;} .caption span {float: left;margin: 0;padding: 2px;width: 100%;background: #222; /* browser che non supportano rgba */ background: rgba(0,0,0,0.7);position: absolute;left: 0;bottom: 0;} .caption span strong {font-weight: bold;font-size: 10px;text-transform: uppercase;display: block;padding-bottom: 5px;} </style> <?php /*if you are getting 404 errors uncomment the next 2 lines*/ //status_header(200); //nocache_headers(); $args = array( 'numberposts' => 6, 'post_status'=>"approved",'post_type'=>"event",'orderby'=>"eventstart",'venue' => "",); $postslist = get_posts( $args ); echo ''; foreach ($postslist as $post) : setup_postdata($post); ?> <?php $venue_id = eo_get_venue(get_the_ID()); $address_details = eo_get_venue_address($venue_id); $state = $address_details['state']; $city = $address_details['city']; ?> <div class="caption"> <?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'thumbnail', array( 'class' => 'attachment-thumbnail eo-event-thumbnail' ) ); } ?> <!-- <?php the_date(); ?> --> " title="<?php the_title();?>"> <?php echo $city; ?> - <?php the_title(); ?> </div> <?php endforeach; ?>
now the script online is so: eventiliguria (point) it/widget-ver.2.php
very good code for iframe banners for partner sites 😉
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Thanks for the code to show $state and $city !!
How do I show for example: “the next 6 events in a defined $state ”
can you help me?Thank you very much
Mario P.December 16, 2016 at 11:54 pm #25395Hi Mario,
Please see http://docs.wp-event-organiser.com/querying-events/getting-events-via-venue-queries/ and http://docs.wp-event-organiser.com/querying-events/querying-venues/ but the following should get the appropriate events:
$events_in_state = eo_get_events( array( 'posts_per_page' => 6, 'venue_query' => array( array( 'key' => '_state', 'value' => $state, ) ), 'event_start_after' => 'today' ));
Stephen HarrisDecember 20, 2016 at 8:06 am #25441Hi Stephen,
I have tested 2 code:
CODE 1 – not works
$events_in_state = eo_get_events( array( 'posts_per_page' => 6, 'venue_query' => array( array( 'key' => '_state', 'value' => $state, ) ), 'event_start_after' => 'today' ));
CODE 2 – works (but not ‘event_start_after’ => ‘today’ )
$events_in_state = array( 'numberposts' => 6, 'post_status'=>"approved",'post_type'=>"event", 'venue_query' => array( array( 'key' => '_state', 'value' => 'Genova', ) ), 'venue' => "", 'event_start_after' => 'today');
What am I doing wrong?
at the beginning the code calls: ” require(‘wp-blog-header.php’); “
and I tried adding require ” (‘ wp-content/themes/sigma/functions.php ‘); “
but same error: does not work ‘ event_start_after ‘ => ‘ today ‘
Mario P.December 20, 2016 at 4:55 pm #25461Hi Mario,
I’m a bit confused, in your first snippet,
$events_in_state
is the value returned byeo_get_events()
which will be an array ofWP_Post
objects (events) or any empty array. In the second, you’re just defining it to be an array. Is that how you’re exactly how you’re using it, or is there a copy-paste error?Also
approved
is not a defaul status for events – have you created a new one?What error are you seeing? In what way does it not work?
Stephen HarrisDecember 20, 2016 at 9:13 pm #25464Hi Stephen,
I’ll use only code 2..w/ “approved” status the script not show event not approved (works, and it’s good for my site 😉 )
I would like to view events in order of “eventstart” today or next week, now the events are in ID order.
test page: eventiliguria.it/widget-ver.2.php
code widget-ver.2.php :
<?php require('wp-blog-header.php'); ?> <style> .caption {font-family: Verdana, sans-serif;font-size: 10px;float: left;margin: 0;padding: 0;position: relative;overflow: hidden;} .caption img {float: left;margin: 0;padding: 0;background: #fff;border: none;} .caption span {float: left;margin: 0;padding: 2px;width: 100%;background: #222; /* browser che non supportano rgba */ background: rgba(0,0,0,0.7);position: absolute;left: 0;bottom: 0;} .caption span strong {font-weight: bold;font-size: 10px;text-transform: uppercase;display: block;padding-bottom: 5px;} </style> <?php $args = array( 'numberposts' => 6, 'post_status'=>"approved",'post_type'=>"event", 'venue_query' => array( array( 'key' => '_state', 'value' => 'Genova', ) ), 'venue' => "", 'event_start_after' => 'today'); $postslist = get_posts( $args ); echo ''; foreach ($postslist as $post) : setup_postdata($post); ?> <?php $venue_id = eo_get_venue(get_the_ID()); $address_details = eo_get_venue_address($venue_id); $state = $address_details['state']; $city = $address_details['city']; ?><div class="caption"> <?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'thumbnail', array( 'class' => 'attachment-thumbnail eo-event-thumbnail' ) ); } ?> <!-- <?php the_date(); ?> --> " title="<?php the_title();?>"> <?php the_ID(); ?><br><?php echo $city; ?> - <?php the_title(); ?> </div> <?php endforeach; ?>
Mario P.December 21, 2016 at 12:51 pm #25479You need to use
eo_get_events()
notget_posts()
.Stephen HarrisDecember 21, 2016 at 5:44 pm #25481All OK ! Thank you very much !
Mario P.July 20, 2017 at 10:11 am #27908Hello,
I try to do this with the calender view. My .php file looks like this:
<?php require('../../../wp-blog-header.php'); ?> <?php echo do_shortcode('[eo_fullcalendar event_venue="aluMINTzium" tooltip="false" defaultView="month" timeFormat="H:i"]'); ?>
I only get a loading circle on the page but no calender. Any idea?
Many thanks!
TobiasJuly 20, 2017 at 8:21 pm #27913You can’t really use the shortcode outside of a WordPress installation. It might work if you add a call to
wp_footer()
afterwards, but I can’t guarantee it will because it’s only intended for use within WordPress.Stephen HarrisSeptember 5, 2017 at 10:35 am #28299Tahnks for the answer. I createt a blank wordpress page and includede the shortcode.
Now I can include this page with an iframe.Thanks for your support!
Tobias -
AuthorPosts