Blog tinkering

If you haven’t spotted already, I’m tinkering (again) with the blog layout.

In particular, I’m working on the design at the bottom of each post. This is also extending to the pages with, and for the first time, the ability to leave comments on them. And after writing a new plugin (coming soon!) for which I’ve learnt all about using custom fields, I’m using them to suppress adverts and comments on specific pages.

Oh, and I’ve done something (reasonably) clever with one my plugins. YARPP (Yet Another Related Posts Plugin) is good but the fixed number of recommendations per post was causing me problems – lots of related posts for a short entry was looking like overkill but, at the same time, large posts were looking a little, erm, lacking. However, the number can be overridden so I’ve updated the plugin call to vary this depending on the blog size. It’s not 100% accurate but, hey, it’s better than it was before.

Here’s the script…

$post_len=strlen($post->post_content);
if ($post_len<1000) {
    related_posts(array('limit'=>2));
} else {
    $max_posts=floor1;
}

As you can see, it’s quite simple. If the number of characters in the post if less than 1000 then it default to a maximum of 2 related posts. It then goes up by 1 at 1000 characters and then again every 3000 characters.

  1. $post_len+2000)/3000)+2; related_posts(array('limit'=>$max_posts[]

Leave a comment

Talk to me!

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll Up
%d bloggers like this: