• Hi Everyone,

    I’m working on a WordPress theme. I was hoping to include a ‘Recent Posts’ section in the footer in exactly the same way that you’ll see on my site (neilcauldwell.com). However, I can’t tell the difference between PHP and Chinese. This means I did a serious bodge job to get what I have on my site, and I’d like a cleaner way of doing it for the new theme.

    Here’s how I did it;

    – I put the (now standard) ‘sidebar widgets’ include in the footer, exactly where the ‘Recent Posts’ section is.

    – (This is where it does down hill) I edited the ‘widgets.php’ plugin script, so that the ‘Recent Posts’ widget only displayed three posts instead of the default five.

    – I used the visual WP admin interface to plonk the ‘Recent Posts’ into the sidebar (which is actually my footer), and everything works as intended.

    But that isn’t a clever way of doing things, because it means that the ‘widgets.php’ is no longer the standard ‘sidebar widgets’ script which WordPress officially supports.

    – I believe I would be much better-off with a custom script which does the following, independently of the ‘sidebar widgets’ plugin;

    [code]

    function widget_recent_entries($args) {
    extract($args);
    $title = __('Recent Posts', 'widgets');
    $r = new WP_Query('showposts=3&offset=1');
    if ($r->have_posts()) :
    ?>
    <?php echo $before_widget; ?>
    <?php echo $before_title . $title . $after_title; ?>

      <?php while ($r->have_posts()) : $r->the_post(); ?>
      <li class="recent_post">"><?php if ( get_the_title() ) the_title(); else the_ID(); ?><p class="info">Posted <?php the_time('F'); ?> <?php the_time('jS Y'); ?> under <?php the_category(' & ') ?> <?php edit_post_link(); ?></p><?php the_excerpt(); ?><p><?php comments_popup_link('0', '1', '%', 'commentlink', ''); ?></p>

      <?php endwhile; ?>

    <?php echo $after_widget; ?>
    <?php
    endif;
    }

    [/code]

    Could anyone make that work as a standalone script, or maybe know of another script I could use? If so, it’ll be mucho apprecio!

    I’m also after a script that generates the top five categories on the site. Once again, if you know how to do this, it’ll be mucho apprecio!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Top 5 categories and last 3 posts’ is closed to new replies.