editing time frame of this

Discussion in 'PHP' started by techblog, Dec 8, 2006.

  1. #1
    ok, this code isplays a list of today posts. Useful for bloggers who publish multiple posts in a day.

    Ok, I'm trying to tweak this so at the end of each week is has this instead, what do you guys think?

    also, which would you edit? I was playing around withit before..

    function cypher_todayposts($before = '<li>', $after = '</li>', $limit = 10) {

    global $wpdb;

    $date_format = get_settings('date_format');
    $current_date = current_time('mysql');
    $today = mysql2date($date_format, $current_date);
    $ada = 0;

    $output = $today . '<br />';

    $request = "SELECT ID, post_title, post_date FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date DESC LIMIT $limit";
    $posts = $wpdb->get_results($request);
    if($posts){
    foreach ($posts as $post){
    $post_title = stripslashes($post->post_title);
    $permalink = get_permalink($post->ID);
    $post_date = stripslashes($post->post_date);

    $today_post = mysql2date($date_format, $post_date);

    if( $today_post == $today ){
    $output .= $before . '<a href="' . $permalink . '" rel="Bookmark" title="Permanent Link to ' . $post_title . '">' . $post_title . '</a>' . $after;
    $ada = 1;
    }
    }
    }

    if( $ada == 0 )
    $output .= $before . 'Sorry, currently there are no updates at this time.' . $after;

    echo $output;
    }
    ?>
     
    techblog, Dec 8, 2006 IP
  2. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #2
    done ......
     
    krakjoe, Dec 8, 2006 IP