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 6 years, 7 months ago.

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #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 7 years, 4 months ago by  Stephen Harris.
    Mario P.
    #25378

    Hi 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 Harris
    #25385

    Hi 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.
    #25395

    Hi 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 Harris
    #25441

    Hi 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.
    #25461

    Hi Mario,

    I’m a bit confused, in your first snippet, $events_in_state is the value returned by eo_get_events() which will be an array of WP_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 Harris
    #25464

    Hi 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.
    #25479

    You need to use eo_get_events() not get_posts().

    Stephen Harris
    #25481

    All OK ! Thank you very much !

    Mario P.
    #27908

    Hello,

    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!

    Tobias
    #27913

    You 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 Harris
    #28299

    Tahnks 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
Viewing 12 posts - 1 through 12 (of 12 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.