• The code below makes an “events list” by sorting ALL POSTS with something in the 05/09/2012 format in the meta tag in chronological order. How can I tell it to only look at a category? So I could create second events list?

    <?php
    // Build a custom query to get posts from future dates.
    $querystr = "
        SELECT wposts.*
        FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
        WHERE wposts.ID = wpostmeta.post_id
    AND wpostmeta.meta_key = 'Date'
    AND STR_TO_DATE(wpostmeta.meta_value,'%m/%d/%Y <span class=\"hide\">%H:%i</span>') >= CURDATE()
    
    AND wposts.post_status = 'publish'
    AND wposts.post_type = 'post'
    
    ORDER BY STR_TO_DATE(wpostmeta.meta_value,'%m/%d/%Y <span class=\"hide\">%H:%i</span>') ASC
    LIMIT 200
    ";
    
    $events = $wpdb->get_results($querystr, OBJECT);
    
     if ($events):
     	foreach ($events as $post):
     		global $post;
     		setup_postdata($post); ?>
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Sorting by meta AND category’ is closed to new replies.