Codex tools: Log in / create account
Contents |
When you lean towards someone and tell them a little bit of information, you are making an "aside" comment. In blogs, you can do that on your blog by passing on small bits of information to your readers called Asides.
Also known as remaindered links or linkblog, Asides were originally implemented by Matt Mullenweg, developer of WordPress, and it soon spread far and wide and became a very popular method of adding little bits of information to your blog.
Asides can be run from within your WordPress site, and do not require installation of another blog. All you need is a few lines of code, and a new category.
Using Asides requires you to make some changes in the WordPress Loop, but if you are careful, everything will be all right.
The MiniPosts2 plugin allows you to flag any post as an aside, without having to edit code or create special categories. It uses the widgets plugin to allow you easy control over the placement of your aside list in your sidebar. To mark a post as an aside, you just have to check a box on the post edit page.
See also SideBlog which runs as a widget or via normal sidebar hacking.
The AsideShop plugin allows you to show aside posts on your blog's frontpage in a different way without theme template modification. Make a template in Administration Panel and assign it to a category which contain aside posts. AsideShop does not add any information to posts or categories.
If you are comfortable editing PHP files, then these two approaches are for you.
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php //if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php
if ($posts)
{
function stupid_hack($str)
{
return preg_replace('|</ul>\s*<ul class="linklog">|', '', $str);
}
ob_start('stupid_hack');
foreach($posts as $post)
{
the_post();
?>
<?php if ( in_category(14) && !is_single() ) : ?>
<ul class="linklog">
<li id="p<?php the_ID(); ?>"><?php echo wptexturize($post->post_content); ?>
<span><?php comments_popup_link('(0)', '(1)',
'(%)')?> <a href="<?php the_permalink(); ?>"
title="Permalink: <?php echo
wptexturize(strip_tags(stripslashes($post->post_title), '')); ?>"
rel="bookmark">#</a> <?php edit_post_link('(e)'); ?></span></li>
</ul>
<?php else: // If it's a regular post or a permalink page ?>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
<?php endif; // end if in category ?>
<?php
}
}
else
{
echo '<p>Sorry no posts found.</p>';
}
?>
That's it. Asides should now be working. Only thing that remains is styling the CSS.
What we've done is create a very basic style. You should add your own style to blend it in with the rest of your site.
To style the Asides, add these example lines to the CSS:
ul.linklog li {
border:1px solid #ff0000;
font:Verdana;
font-size:14pt;
background-color:#ffff00;
}
ul.linklog li a {
text-decoration:none;
}
There are times when you want to display your Asides in your sidebar. In the sidebar.php template file of your WordPress Theme, add the following where you wish the asides to appear. If you want them outside of the list, make sure to position this above or below the Unordered List (<ul>) tags or within them as a List Item (<li>):
<?php
if ($posts) : foreach ($posts as $post) : the_post();
?>
<?php if (in_category(14)) { ?>
<div class="asides_sidebar">
<?php echo $post->post_excerpt ?> <?php the_content(); ?>
<small><?php comments_popup_link(__('#'), __('(1)'), __('(%)')); ?>
<?php edit_post_link('Edit', ' — '); ?></small>
</div>
<?php } ?>
<?php endforeach; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
Now, you can style the CSS for the div "asides_sidebar" to your liking in the style.css style sheet.
With Asides in the sidebar, you may want to disable them from being displayed within the main loop. This can be easily done with a snippet of code within the loop.
Find this line within the loop in your main index.php file:
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
Just after that line, paste this line (change the 14 to your category ID number):
<?php if (in_category('14') && is_home() ) continue; ?>
After that, you will then need to find this line:
<?php endwhile; ?>
And just before that line, paste this:
<?php } ?>
After doing all of that, you will need to put this line:
<?php rewind_posts(); ?>
Either before the loop in your index.php file or before the loop in your sidebar.php file, depending on which one comes last. So, for example, if <?php get_sidebar(); ?> comes after the <?php endif; ?> line in index.php, then you will have to put it before the loop in sidebar.php.
Voila. Asides will now be displayed on the sidebar, rather than within the loop, giving it a more 'linkblog' feel.
This article is marked as in need of editing. You can help Codex by editing it.