• I am sure someone fixed this before, I just need to know what to change this code to in my my-hacks.php file.


    function get_recent_posts($no_posts = 5, $before = '

    • ', $after = '
    • ', $show_pass_post = false, $skip_posts = 0) {
      global $wpdb, $tableposts;
      $request = "SELECT ID, post_title FROM $tableposts WHERE post_status = 'publish' & ";
      if(!$show_pass_post) { $request .= "AND post_password ='' "; }
      $request .= "ORDER BY post_date DESC LIMIT $skip_posts, $no_posts";
      $posts = $wpdb->get_results($request);
      $output = '';
      foreach ($posts as $post) {
      $post_title = stripslashes($post->post_title);
      $permalink = get_permalink($post->ID);
      $output .= $before . '' . $post_title . '' . $after;
      }
      echo $output;
      }

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter phoenixd

    (@phoenixd)

    I don’t want to have to do an ugly date and time comparison… :$

    Thread Starter phoenixd

    (@phoenixd)

    I did the ugly date comparison. I guess its the only way to do it, and it works. 🙂

    function get_recent_posts($no_posts = 5, $before = ‘

    • ‘, $after = ‘
    • ‘, $show_pass_post = false, $skip_posts = 0) {
      global $wpdb, $tableposts;
      $today = date(“Y-m-d H:i:s”);

      $request = “SELECT ID, post_title FROM $tableposts WHERE post_status = ‘publish’ AND post_date < ‘$today’ “;
      if(!$show_pass_post) { $request .= “AND post_password =” “; }
      $request .= “ORDER BY post_date DESC LIMIT $skip_posts, $no_posts”;
      $posts = $wpdb->get_results($request);
      $output = ”;
      foreach ($posts as $post) {
      $post_title = stripslashes($post->post_title);
      $permalink = get_permalink($post->ID);
      $output .= $before . ‘‘ . $post_title . ‘‘ . $after;
      }
      echo $output;
      }

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Latests posts shows future posts Problem’ is closed to new replies.