How to do a miniblog…
-
Go to the Wiki and find the Show Category Posts plug in by Kitten. Install it on your installation of WP and activate it. Create a Category called miniblog and not the number of the category.
There are two steps to this process.
1) removing the miniblog category from your regular blog posts.
2) setting up the miniblog itself
step 1) I used a hack in my-hacks.php to actually remove the miniblog category from the regular blog.
insert this into your my-hacks.php file changing the 25 in the second line to the category # that pertains to your miniblog category.
function the_category_IDs() {
$IDs = array();
$categories=get_the_category();
foreach ($categories as $category)
{
$IDs[] = $category->category_id;
};
return $IDs;
}
function isthree($post) {
return (in_array(25,the_category_IDs()));
}
function remove_posts($function) {
global $posts, $post;
$newposts = array ();
if (stristr($function,’!’))
{
$function = explode(‘!’,$function);
$function = $function[1];
foreach ($posts as $post) {
if ($function($post))
{
$newposts[] = $post;
}
}
} else {
foreach ($posts as $post) {
if (!$function($post))
{
$newposts[] = $post;
}
}
}
return $newposts;
}?>
Insert this line just after the start of the loop in index.php
<?php $posts = remove_posts(‘isthree’) ?>
THAT IS ALL FOR STEP 1. YOUR MINIBLOG CATEGORY SHOULD NOT SHOW UP IN YOUR REGULAR POSTS.
Step 2) insert the following code wherever you store your sidebar/menu (wherever you are putting the miniblog) code.
If you want more or less post than I have in my miniblog edit the post information accordingly. The 25 in the third line should be changed to whatever # corresponds to the number of your miniblog category.
<div id=”miniblog”>
<div id=”menu2″>
<?php echo show_category_posts(’25’); ?><br>
<?php if ($scp_posts) : foreach ($scp_posts as $post) : start_wp(); ?><?php the_date(”,'<h2>’,'</h2>’); ?>
<div class=”storycontent”>
<?php the_content(); ?>
</div>
<div class=”feedback”>
<?php wp_link_pages(); ?>
<?php comments_popup_link(__(‘Comments (0)’), __(‘Comments (1)’), __(‘Comments (%)’)); ?>
</div><?php endforeach; else: ?><?php _e(‘Sorry, no posts matched your criteria.’); ?>
<?php endif; ?></div></div>
This should do it for you! Have fun!
EDIT: I screwed up a couple of lines of code above, they have since been corrected, please use this or copy and paste the code from the link many posts below.
- The topic ‘How to do a miniblog…’ is closed to new replies.