How To Set Up a Sideblog
Since writing about the benefits of a sideblog, the idea has taken off. Sideblogs are a great way of quickly updating your readers. However, you're still left with the problem of how to set one up.
There are various methods, including the use of Twitter or Tumblelog and then importing an RSS feed. However, those methods don't give enough control for me, so the method I'm using is done entirely in WordPress.
Features of A Perfect Sideblog
The purpose of my sideblog is to post links that I would recommend, and to write quick updates about this blog. For that purpose, here is what I would consider the perfect sideblog to be:
- Compact. Show only what needs to be shown. It has to fit easily into your sidebar.
- No post titles. The post title, linking to the entries own page, is not needed. Instead, I'd rather have a headline that was the actual link I'm talking about.
- Comments enabled sometimes. Comments are only needed when you're asking a question, so the ability to turn them on and off at will is a must.
- Separate RSS feed (And preferably an archives page). Not all of your current readers will want this in their feed reader, but some will, so give them the option.
- Posts don't show up on the home page, or in search results.
The Code
Firstly, set up a new category in WordPress (e.g. Called "Asides").
Thanks goes to milo for figuring out how to do this bit without a plugin. Add the following to the functions.php file in your theme (Or if your theme doesn't have one, create a file with this name). Make sure you update the "17" with the ID of your Asides category. Also, make sure that there is no whitespace before or after the php tags.
<?php
function asidesFilter($query) {
if ($query->is_feed || $query->is_home || $query->is_search) {
$query->set('cat','-17');
}
return $query;
}
add_filter('pre_get_posts','asidesFilter');
?>
Now, paste the following into your sidebar (Either in sidebar.php, or in a PHP widget). Make sure to update it with your feed URL, category ID, category URL and number of posts you want to show, as well as any of the text you'd like to personalize.
There is also a line for an RSS image. Feel free to download the image used in my sidebar, and upload it to your own server. You can also update the left:0px; value to choose how far to the right you'd like to position the image.
<h3>Asides
<a href="FEED URL" title="The Asides RSS feed.">
<img src="RSS IMAGE URL" alt="RSS" style="position:relative;left:0px;" /></a></h3>
<?php query_posts('cat=17&showposts=4'); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="aside_post">
<?php the_content('Continue reading this article »'); ?>
<small><?php the_time('F jS Y') ?></small>
</div>
<?php endwhile; ?>
<span class="aside_archive_link"><a href="CATEGORY URL" title="More asides.">Archives »</a></span>
<?php else : ?><p>Sorry, the sideblog is having a little trouble.</p>
<?php endif; ?>
If you have any trouble, feel free to ask for help in the comments. And if you have any success, make sure you post your link, to let us see how things worked out.
Enjoy this post? Get future updates sent to you for free! Join by email or RSS.
Other posts tagged with Plugin, Sidebar, Sideblog, WordPress.

9th November, 12:58 pm GMT
You're too kind Michael,
I just gave the base code, from there is still some more tweaks to do.
btw: you can place the exec.php pi code into the theme functions.php too.
9th November, 3:53 pm GMT
I used the sideblog plugin (http://katesgasis.com/2006/05/.....lugin-v30/) and it is working great for me. I really like having a sideblog. Thanks for giving me the idea to do this!
9th November, 4:19 pm GMT
How timely! I'd seen asides on other sites and last night I started to try and code one myself, you've saved me a bit of hassle, thanks.
9th November, 4:34 pm GMT
Michael, I just wrote about an an alternate way to set up a sideblog that I am currently using on my blog.
9th November, 7:17 pm GMT
Milo - Never! Thanks again. :p
Pat - The plugin looks great, and I'm glad it's working for you.
Colin - Good luck!
Mohsin - That's a great way of doing it!
9th November, 8:42 pm GMT
Thanks Michael. I've been thinking about a sideblog since you brought it up last week and trying to come up with ideas for what I would want to display.
Now you've saved me the time of figuring out how to code it in there too. Thanks
9th November, 8:47 pm GMT
Glad you like the idea as well Steven. They're good fun for both the reader and the blogger I think.
9th November, 10:29 pm GMT
very useful post.
thanks a lot
10th November, 5:33 am GMT
Thanks a lot
Very useful.
10th November, 8:37 am GMT
I love the idea of the sideblog but I can't seem to get this one to work correctly. I installed ExecPHP, inserted the codes in their proper places, but when I refresh my site's page, I get an error:
Parse error: syntax error, unexpected T_STRING
in functions.php.
Can anyone help me figure out what I'm doing wrong (using Wordpress 2.3.1)? Any help would be greatly appreciated. Thanks!
10th November, 9:12 am GMT
Sorry, I decided to go with Pat's method. You can disregard my previous post but thanks for putting me onto sideblogs!
10th November, 2:27 pm GMT
Just one doubt, Michael:
Does this bit of code help in removing asides posts from the main WP loop? Or, will it appear twice, once in sidebar and once in main content?
Also, like Beth, I too get the same PHP error. I have made sure to delete any space after and before the php tags, so that's not the problem. It shows an error on line 8, which is second-last.
Unlike Beth, I'd like to keep things optimized, so I figure that the plugin would be against that interest. Please look up the issue and make a fix.
10th November, 2:55 pm GMT
The error *might* be coz of code copy-paste errors. I hand-copied the code and used it from source and it worked.
If someone's interested, here's a clean, working, stable version of the code, available as a .txt file (Michael, please edit your code to the text file one, or better, link to it [I'm running low on appreciating audience like yours, though I write regularly, and not rehashed content]
)
10th November, 2:58 pm GMT
Its probably because of your apostrophes turning to smart quotes....WP's editor and many others have such problem.
Just paste the code to code view and publish immediately after. And do not switch back to visual mode before publishing. Hope it helps
I learnt it the hard way too.
10th November, 3:02 pm GMT
Oops, oversaw that asidesFilter function. So the doubt is cleared. Now another one, how do the link to 3rd party site show up on the headings of asides?
10th November, 3:55 pm GMT
Beth - Sorry for the trouble. I think Sumesh is right about what's causing the errors (WordPress text editor playing with things that it shouldn't...
)
Sumesh - That will remove it from the main content as well. The only place it might still show up is as a link to the Asides category in your sidebar (Like it does on PBD at the minute. If you're using widgets, like I am, there doesn't seem to be an easy way to exclude the category unfortunately...
)
Thanks though. I think you're right about the error. I'm going to disable the visual editor completely. I've lost count of how many times it has caused codes to break on me...
As for how the aside headers work, they're actually a part of the post content. I just put a
into a post, and have set up the CSS to display sidebar h4s like headers.
10th November, 5:55 pm GMT
This is great, I always love finding that someone has done the hard work for me! Thanks very much!
10th November, 7:10 pm GMT
Michael, I meant to ask how it points to the outbound link rather than the post link itself. Also, there seems to be no php tag for the post header, just the php the_content tag.
I have set everything else up, waiting for clarifications on this to deploy it
10th November, 7:12 pm GMT
Oops, sorry, understood it now that I made the comment.
As for CSS, piece of cake - I love it and am good, though not at a pro level as you
10th November, 7:14 pm GMT
As for enabling comments, I believe it should be done when in post editor. But does it show up as a link in the sidebar, say "Comments" ? Otherwise, readers wouldn't be able to make out whether comments are enabled or not.
10th November, 7:20 pm GMT
Thanks for enlightening me about Sideblog knowledge
10th November, 7:20 pm GMT
Sumesh - I should have clarified the answers to your questions in the article.
The comments link would be the same principle as the header link. You would just have to do it in the content of the aside. It's not as convenient as having the theme do it for you, but I won't be using comments often, so it works for me.
10th November, 7:21 pm GMT
Madhur - No problem.
11th November, 11:47 am GMT
I just set up a "sideblog" with this technique. I tried quite a few things before I found this post, thanks Michael.
Now I only have one problem, and that is that the "mini posts" show up on my archives page.
I guess I have to live with that, unfortunately
Thanks for the code!
Take care,
Alex
11th November, 11:36 pm GMT
Hey,
Nice work on this.
I will consider doing something like this, although I'm not sure if it's suited to my blog. Might help for more regular updates, or it might just turn into "Went sailing today - it was awesome!" type of updates. Although maybe for a personal blog that's not such a bad thing. Don't know, will think more.
Anywho, I don't think that code showed up in your comment correctly. Are you saying that for the heading links you used
<h4><a href="http://...">Heading Link</a><h4>within the content of the post? That's how I'd do it I guess.I've never been impressed with the rich text editor of WP (is that what was giving you problems?) - I always use the plain text. The quick tags are pretty handy; in general I prefer to hand code everything to make sure it's doing the right thing.
11th November, 11:37 pm GMT
Doh! could you fix that </a to </a?
Haha! Hand-coding doesn't always work for me in comments!
12th November, 12:34 am GMT
Kristarella - Yep, that's how I'm doing it.
And yeah, the "code" editor makes a right mess of code. After commenting above, I actually installed a plugin that stops it from playing with the " and ' punctuation marks. Hopefully it will leave them alone from now on!
17th November, 12:52 am GMT
Hi...
Gave this to a colleague....works a treat.
Thank you from Ireland
19th February, 8:12 am GMT
I tried to setup a sideblog like you described with one little change - I used this code for my sidebar:<?php query_posts('cat=3&showposts=5'); ?><?php if (have_posts()) : ?><?php while (have_posts()) : the_post(); ?><h1><?php the_title(); ?></h1><p class="sideblog"><?php the_content(); ?></p><?php endwhile; ?><?php else : ?><p>Sorry, the sideblog is having a little trouble.</p><?php endif; ?>what I don't get is why this code produces something like this<p></p> [posts correctly formated] <p></p>I have no idea why it shows this <p> that break my complete design...any idea?
19th February, 7:55 pm GMT
Pharao,
The <p> elements stand for paragraph. It's normal, semantic coding.
All the code does for the content here is to pull the content from the WordPress database. The <p> elements are all contained in the post itself, so if there's something wrong with them, you might need to edit your posts (Hit the "Code" view on some of your posts to see what's up).
Otherwise, it might just be that your CSS stylesheet doesn't have any rules for dealing with paragraphs in your sidebar, so they look a little ugly right now?
20th February, 7:38 am GMT
uh - got it...I had to remove the <p>'s form <?php get_content() ?>stupid problem - what I didn't get is why the code view doesn't show me p's but wordpress outputs them.(stylesheet was working - I first insert a lorum ipsum in my template before I make the WP-theme to see that it works as expected)thanks for your help
4th August, 3:57 am GMT
Its been a long time but i got this problem.
When I use your code, the "asides" work perfectly. But the other post (other than aside) sorted in the opposite way. The first post should be under the second post, but in this case the first post always stay on top of the second post.
8th October, 5:20 pm GMT
could you insert that code into blodspot as well...