WordPress.org

Ready to get started?Download WordPress

Forums

Previous 7 Days (4 posts)

  1. Lucid
    Member
    Posted 9 years ago #

    I have wp set up to display the most recent 7 Days on my home page (www.stirman.net) You'll notice on my sidebar I have a section called "previously". I would like for this to display the week before the current week, or posts from 7-14 days ago, make sesne? OR, (this might be easier), display a fixed number of entries previous to the last enty being displayed on the home page.

    I am using the previous_posts plug-in right now, but it's working correcty, the list never changes, dunno why...

    Thanks!

  2. silverberry
    Member
    Posted 9 years ago #

    add this

    function get_recent_posts($no_posts = 6, $before = '<li>', $after = '</li>', $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 . '<a href="' . $permalink . '" rel="bookmark" title="Permanent Link: ' . $post_title . '">' . $post_title . '</a>' . $after;
    }
    echo $output;
    }

    in your my-hacks.php file ....

    then use this

    <?php get_recent_posts(10, '', '<br />', true, 7); ?>

    to call the 10 posts BEFORE the most recent 7 posts ...

    make sense?

  3. dtclarinet
    Member
    Posted 9 years ago #

    is there a my-hacks.php file in wp 1.5?

  4. Kafkaesqui

    Posted 9 years ago #

    If it isn't there just create it (add to the root directory of the blog). Also make sure "Use legacy my-hacks.php file support" is checked under Options > Miscellaneous.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.