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.
Custom Search
milo (72 comments)9 November 07
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.
Pat B. Doyle (2 comments)9 November 07
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!
Colin King (2 comments)9 November 07
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.
Mohsin (28 comments)9 November 07
Michael, I just wrote about an an alternate way to set up a sideblog that I am currently using on my blog.
Michael Martin (1286 comments)9 November 07
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!
Steven Bradley (7 comments)9 November 07
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
Michael Martin (1286 comments)9 November 07
Glad you like the idea as well Steven. They’re good fun for both the reader and the blogger I think.
Babak M (1 comments)9 November 07
very useful post.
thanks a lot
Felipe Cerda (1 comments)10 November 07
Thanks a lot
Very useful.
Beth (2 comments)10 November 07
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!
Beth (2 comments)10 November 07
Sorry, I decided to go with Pat’s method. You can disregard my previous post but thanks for putting me onto sideblogs!
Sumesh (39 comments)10 November 07
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.
Sumesh (39 comments)10 November 07
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]
)
Sumesh (39 comments)10 November 07
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.
Sumesh (39 comments)10 November 07
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?
Michael Martin (1286 comments)10 November 07
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.
Web Design :: Alex (1 comments)10 November 07
This is great, I always love finding that someone has done the hard work for me! Thanks very much!
Sumesh (39 comments)10 November 07
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
Sumesh (39 comments)10 November 07
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
Sumesh (39 comments)10 November 07
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.
Madhur Kapoor (12 comments)10 November 07
Thanks for enlightening me about Sideblog knowledge
Michael Martin (1286 comments)10 November 07
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.
Michael Martin (1286 comments)10 November 07
Madhur – No problem.
Alex Kay (7 comments)11 November 07
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
kristarella (141 comments)11 November 07
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.
kristarella (141 comments)11 November 07
Doh! could you fix that </a to </a?
Haha! Hand-coding doesn’t always work for me in comments!
Michael Martin (1286 comments)12 November 07
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!
Mark Hayes (1 comments)17 November 07
Hi…
Gave this to a colleague….works a treat.
Thank you from Ireland
Pharao (2 comments)19 February 08
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?
Michael Martin (1286 comments)19 February 08
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?
Pharao (2 comments)20 February 08
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
ayas (1 comments)4 August 08
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.
mad architect (1 comments)8 October 08
could you insert that code into blodspot as well…
Ceveni (1 comments)19 January 10
Any idea how to do this on blogger blogs?
Иван (2 comments)2 February 10
Расскрутка сайта. На данном портале вы найдете всю необходимую информацию по расскрутке веб-сайтов в сети интернет.
Иван (2 comments)6 February 10
Не плохой ресурс но сильно поттупливает при загрузке страниц, хотя канал хороший!