• Hi Barry thanks for responding to my personal email and as requested have brought it to the forum.

    I have got this far:

    function sie_events(){
    $thisDate = date(“Y-m-d”);
    $thisDate7 = date(“Y-m-d”,strtotime(“+1 week”));

    $event_posts = event_embed()->obtain( [
    ‘from’ => $thisDate,
    ‘to’ => $thisDate7
    ] );
    echo($thisDate . ” to “. $thisDate7 . “
    “);
    // Now you can iterate through the results and do // whatever you like
    foreach ( $event_posts as $single_event ) {
    $url = get_permalink( $single_event->ID );
    $title = get_the_title( $single_event->ID );
    echo ‘event: ‘ . $title . ‘‘;

    }

    }
    add_shortcode(‘SiE_Events’, ‘sie_events’);

    I do get the echo of the date come up: 2015-05-12 to 2015-05-19 but no events to which I know there is at least 25 for the date period.
    I’d also like to add start date to the event.

    Thanks in advance

    https://wordpress.org/plugins/event-rocket/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter makcooney

    (@makcooney)

    The HTML has disappeared from above

    function sie_events(){
    	$thisDate = date("Y-m-d");
    	$thisDate7 = date("Y-m-d",strtotime("+1 week"));
    
    	$event_posts = event_embed()->obtain( [
    	'from' => $thisDate,
    	'to'   => $thisDate7
    	] );
    	echo($thisDate . " to ". $thisDate7 . "<br />");
    // Now you can iterate through the results and do // whatever you like
        foreach ( $event_posts as $single_event ) {
        $url   = get_permalink( $single_event->ID );
        $title = get_the_title( $single_event->ID );
       echo 'event: <a href="' . $url . '">' . $title . '</a>';
    
     }
    
    }
    add_shortcode('SiE_Events', 'sie_events');
    Plugin Author Barry

    (@barryhughes-1)

    Thanks makcooney – you’ve actually hit upon a bug here. Hold tight while I make a correction.

    Plugin Author Barry

    (@barryhughes-1)

    2.5.2 should be available shortly: as soon as it is, please try it out alongside your custom shortcode 🙂

    Thread Starter makcooney

    (@makcooney)

    great stuff – update works

    So how do I get the start date and limit to 50 please?

    Thanks for your help Barry

    Thread Starter makcooney

    (@makcooney)

    and to be really annoying, can it be Day of week (full), date Month?

    Thread Starter makcooney

    (@makcooney)

    OK kinda figured it. Like I say novice.

    The only part that dont work is the date_format. Maybe guidance there is possible. Thanks again for your help

    function sie_events(){
    	$thisDate = date("Y-m-d");
    	$thisDate7 = date("Y-m-d",strtotime("+1 week"));
    
    	$event_posts = event_embed()->obtain( [
    	'from' => $thisDate,
    	'to'   => $thisDate7,
    	'limit' => '50'
    	] );
    	echo($thisDate . " to ". $thisDate7 . "<br />");
    // Now you can iterate through the results and do // whatever you like
        foreach ( $event_posts as $single_event ) {
        $url   = get_permalink( $single_event->ID );
        $title = get_the_title( $single_event->ID );
    	$datd = tribe_get_start_date( $single_event->ID, false, get_option( 'date_format', 'l j F' ) );
       echo 'event: <a href="' . $url . '">' . $datd . " " . $title . '</a> <br/>';
    
     }
    }
    add_shortcode('SiE_Events', 'sie_events');
    Plugin Author Barry

    (@barryhughes-1)

    So how do I get the start date and limit to 50 please?

    The start date of each event? Use tribe_get_start_date() for that. To specify a limit just add a limit argument in the array you are passing to event_embed()->obtain() 🙂

    and to be really annoying, can it be Day of week (full), date Month?

    It can be whatever you want! You can learn about date formatting in PHP (which is what tribe_get_start_date() uses under the hood) over here:

    php.net/manual/en/function.date.php

    Thread Starter makcooney

    (@makcooney)

    Sorted 😛

    $datd = tribe_get_start_date( $single_event->ID, false, 'l jS F' );

    No need for the get_option part

    Barry, your a star.

    Plugin Author Barry

    (@barryhughes-1)

    Happy to help 🙂

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Programming event list’ is closed to new replies.