Improve your WordPress Theme with Snippets of Code

No Comments
Tags: ,
Posted 18 Mar 2009 in WordPress

I love WordPress because it is so easy to modify to fit your needs. Some tweaks can make your theme more personal, others add functionality to tell your visitors more about you as a blogger. Take these four tweaks, add them to your WordPress blog, and see how it improves your blogging experience!

Add the number of posts to your sidebar:

<?php
$my_query = new WP_Query('post_status=future&order=DESC&showposts=5');
if ($my_query->have_posts()) {
    while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <?php the_title(); ?>
    <?php endwhile;
}
?>

Add “Tweet This” to your posts by placing this code in “The Loop” in single.php

<a href="http://twitter.com/home?status=I just read <?php the_permalink(); ?>" title="Send this page to Twitter!" target="_blank">Tweet This!</a>

Add an additional “Edit” button to each post, where ever you need the code – add this code in either single.php or index.php, where ever your post code is :

<?php edit_post_link('Edit', ''); ?>

Display your upcoming/scheduled posts in the sidebar:

<?php
$my_query = new WP_Query('post_status=future&order=DESC&showposts=5');
if ($my_query->have_posts()) {
    while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <?php the_title(); ?>
    <?php endwhile;
}
?>
Blog Widget by LinkWithin

Comments are closed.