This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

display future posts

By: thorbj on Jun 29th, 2011  |  syntax: PHP  |  size: 0.77 KB  |  views: 177  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <ul>
  2. <?php
  3. // Build a custom query to get posts from future dates.
  4. $querystr = "
  5.    SELECT wposts.*
  6.    FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
  7.    WHERE wposts.ID = wpostmeta.post_id
  8.         AND wpostmeta.meta_key = 'Dato'
  9. AND STR_TO_DATE(wpostmeta.meta_value,'%d/%m/%Y') >= CURDATE()
  10.  
  11. AND wposts.post_status = 'publish'
  12. AND wposts.post_type = 'post'
  13. ORDER BY STR_TO_DATE(wpostmeta.meta_value,'%d/%m/%Y') ASC
  14. LIMIT 3
  15. ";
  16.  
  17. $events = $wpdb->get_results($querystr, OBJECT);
  18.  
  19.  if ($events):
  20.         foreach ($events as $post):
  21.                 global $post;
  22.                 setup_postdata($post); ?>              
  23.                         <li>
  24.                         <?php the_meta(Dato); ?><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
  25.                         </li>
  26.         <?php endforeach;
  27. else : ?>
  28.         <li>Can't find any posts...</li>
  29. <?php endif; ?>
  30. </ul>
clone this paste RAW Paste Data