5 Great WordPress Hacks

11 Comments
Tags: ,
Posted 12 Aug 2009 in WordPress

wordpressWordPress is a great blogging and content-management tool. It is highly extensible, evidenced by the thousands of plugins available for it, but also the WordPress Codex, where you can learn all things related to making WordPress work best for you.

Below, you’ll find 5 great WordPress hacks that add functionality to your site without sacrificing a lot of time or energy.

1. List your upcoming posts. Do you write a lot of posts in advance? Generate buzz for them by posting a list of your upcoming posts in the sidebar. Paste the following code where you want the list to display:

<div id=”zukunft”>
<div id=”zukunft_header”>

Future events
</div>

<?php query_posts(‘showposts=10&post_status=future’); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div>
<p><b><?php the_title(); ?></b><?php edit_post_link(‘e’,’ (‘,’)’); ?>

<span><?php the_time(‘j. F Y’); ?></span>
</p></div>

<?php endwhile; else: ?>

No future events scheduled.

<?php endif; ?>
</div>

2. Show your most popular posts without a plugin. Change the number 5 in line 4 to whatever number you want, for more or less popular posts to display.

<h2>Popular Posts</h2>
<ul>
<?php $result = $wpdb->get_results(“SELECT comment_count,ID,post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , 5″);
foreach ($result as $post) {
setup_postdata($post);
$postid = $post->ID;
$title = $post->post_title;
$commentcount = $post->comment_count;
if ($commentcount != 0) { ?>

<li><a href=”<?php echo get_permalink($postid); ?>” title=”<?php echo $title ?>”>
<?php echo $title ?></a> {<?php echo $commentcount ?>}</li>
<?php } } ?>

</ul>

3. Send pages to Twitter by pasting this code where you want the link to display in single.php. Further modify by adding an image or the title of the individual post:

<a href=”http://twitter.com/home?status=Currently reading <?php the_permalink(); ?>” title=”Click to send this page to Twitter!” target=”_blank”>Share on Twitter</a>

4. List all of the authors of your blog. Helpful for providing links to authors’ posts on your multi-author blog, just paste this code where you want the link to display:

<ul>
<?php wp_list_authors(‘exclude_admin=0&optioncount=1&show_fullname=1&hide_empty=1’); ?>
</ul>

Edit the parameters to customize the display:

  • exclude_admin: 0 (include the admin’s name in the authors list) / 1 (exclude the admin’s name from the list)
  • optioncount : 0 (No post count against the author’s name) / 1 (display post count against the author’s name)
  • show_fullname : 0 (display first name only) / 1 (display full name of the author)
  • hide_empty : 0 (display authors with no posts) / 1 (display authors who have one or more posts)

5. Post to your RSS feed 5 minutes later. Sometimes, we hit publish too soon and leave a typo or error in our post. Delaying the publishing of the feed for five minutes can save you a lot of embarrassment. Paste this code into your functions.php file on your theme.

function publish_later_on_feed($where) {
global $wpdb;

if ( is_feed() ) {
// timestamp in WP-format
$now = gmdate(‘Y-m-d H:i:s’);

// value for wait; + device
$wait = ‘5’; // integer

// http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_timestampdiff
$device = ‘MINUTE’; //MINUTE, HOUR, DAY, WEEK, MONTH, YEAR

// add SQL-sytax to default $where
$where .= ” AND TIMESTAMPDIFF($device, $wpdb->posts.post_date_gmt, ‘$now’) > $wait “;
}
return $where;
}

add_filter(‘posts_where’, ‘publish_later_on_feed’);

Do you have a favorite hack? Tell us in the comments!

Blog Widget by LinkWithin

5 Comments

  1. How about using Author Avatars List http://wordpress.org/extend/plugins/author-avatars/ to list the authors

    • Great suggestion, Paul!

  2. thanks you for these hacks

  3. Great hacks! I love the “Post to your RSS feed 5 minutes later”…

  4. I agree with Jef, the “post to your RSS feed 5 minutes later” hack is far and away the best of the bunch.


6 Trackbacks/Pingbacks

  1. Posts about SEO as of August 12, 2009 | All About WordPress 12 08 09
  2. Twitted by thepinkc 12 08 09
  3. 5 Great WordPress Hacks | ultimate geek girl 12 08 09
  4. 5 Great WordPress Hacks | ultimate geek girl 12 08 09
  5. 5 Great WordPress Hacks | ultimate geek girl | Squico 12 08 09
  6. 5 Great WordPress Hacks | ultimate geek girl | WpMash - WordPress News 12 08 09