• I modified this function for showing events on a page but i dont know how to sort it by date or title?

    Can someone help me?

    <?php // TICKERA ALL EVENTS
    add_shortcode( 'tc_all_events', 'tc_all_events' );
    function tc_all_events() {
    $wp_events_search = new TC_Events_Search( '', '', '', 'publish' );
    foreach ( $wp_events_search->get_results() as $event ) {
    // echo '<div class="smticketcalendar"><h3>' . $event->post_title . '</h3>';
    echo '<div class="smtickets"><div class="smticketstitle"><a id="SM-'.$event->ID.'"  href="'.$event->guid.'">'.$event->post_title.'</div></a>';
    echo '<div class="smticketsdate">' . mysql2date('l, \d\e\r d. F Y \u\m H:i \U\h\r', $event->event_date_time ). '</div>';
    echo '<div class="smticketslocation">' . $event->event_location . '</div>';
    echo '<div class="smticketshide" tabindex="0"><div class="smticketstickets">TICKETS</div>' . do_shortcode( '[tc_event id="' . $event->ID . '"]' ).'</div></div>';
    } }
    ?>
Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Steelclover

    (@steelclover)

    if i type behind the link

    /?orderby=event_date_time&order=asc

    it doesnt affect something

    Moderator bcworkz

    (@bcworkz)

    Ideally, the TC_Events_Search class would have some sort of orderby argument much like the WP_Query class does. Since TC_Events is not part of the WP core I wouldn’t know if that’s possible or not.

    What you can do is use usort() on $wp_events_search before the loop.

    BTW, you do not want to echo out content from within a shortcode handler. You can get misplaced output by doing so. Instead, collect all the output into a single HTML string. Return that string at the end of the handler function and do_shortcode() (external to your code) will echo out that HTML at the correct location.

    Thread Starter Steelclover

    (@steelclover)

    awesome! Thanks a lot

    hey i cant type the info because its too long, just read this it will help you https://www.w3schools.com/sql/sql_orderby.asp

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Order by date – where to put in’ is closed to new replies.