• I have a sidebar which spits out posts with a category of event from the posts section of the dashboard.

    I have the posts being order correctly by their respective starting dates

    However,

    I would like to have the event show only if the ending date is greater than the system date meaning, if the event is over, do not show it in the upcoming events panel.

    How could i do this? I have something similar to this right now for my query:

    <? query_posts(‘category_name=Events’ . ‘&orderby=meta_value&meta_key=eventDateStart&order=ASC’ . ‘&posts_per_page=5’); ?>

    Thanks!

    -Derek

Viewing 1 replies (of 1 total)
  • vtxyzzy

    (@vtxyzzy)

    This is UNTESTED, but should be close:

    Be sure to check the meta_key name I used – it is a guess.

    function mam_posts_join ($join) {
       global $mam_global_join;
       if ($mam_global_join) $join .= " $mam_global_join";
       return $join;
    }
    add_filter('posts_join','mam_posts_join');
    $sysdate = date('Y-m-d');
    $mam_global_join = "JOIN $wpdb->postmeta meta2 ON (meta2.post_id = $wpdb->posts.ID AND meta2.meta_key = 'eventDateEnd' AND meta2.meta_value < '$sysdate')";
    query_posts('category_name=Events' . '&orderby=meta_value&meta_key=eventDateStart&order=ASC' . '&posts_per_page=5');
    $mam_global_join = '';
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Custom field issue help’ is closed to new replies.