Support » Fixing WordPress » 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.

Viewing 15 replies - 1 through 15 (of 24 total)
  • Excellent, good snake! Thanks for the HowTo. Could be at the wiki too 🙂

    This is such a stupid question. But what is this my-hacks.php thing? I don’t know a lot about .php or what this does. And I don’t know how to go about getting it on or starting it. I clicked the check box in the options area, and then went to the templates and tried to view it, but it says it doesn’t exist. I don’t have one. Errk! Where do I get one, who do I have to sleep with around here for one?

    Thread Starter goodsnake

    (@goodsnake)

    go to my site, use the contact form to send me your email address and I will email you a my-hacks.php file that you can just upload to your site and it will work for you.

    Actually, I just found that in the wiki. I’m a lil slow today. But thank you. 🙂
    I shall be attempting this…

    Pardon my ignorance, but what does this mean:
    “Insert this line just after the start of the loop in index.php”
    What is “the loop”?
    Cheers
    Scott

    I think this explains what the loop is: http://wiki.wordpress.org/TheLoop
    And I found all by myself!
    *all proud of me self 🙂

    Johnnie: I’m getting that, too.

    u guys enabled my-hacks.php from the backend?

    Sushubh means to say that you have to enable the my-hacks.php support in Options->Miscellaneous for functions in that file to be used/considered.

    Yup. Enabled. No blank space in the my-hacks. Here’s the error:
    Fatal error: Call to undefined function: the_category_ids() in /home/scott/public_html/scott/wp/my-hacks.php on line 3

    You might not have enabled the plugin.
    Try to find out which file you newly added/modified has the function the_category_ids() and see if it is enabled. See if you have the file that contains that function first.

    I enabled (activated) the plugin’ from kitten. And the legacy my-hacks.php is checked in the options area. But still an error. I get the mini blog showing up, but the main blog area gives me that error.

    Kitten says that there’s something in that function that calls for code the original poster didn’t provide. Also says that the next version of show_categories plugin (due, perhaps, tomorrow) will feature the miniblog….

    Ok, I have no idea what that means. I did what I was suppose to I think. I hope. I can’t see anything I left out.

Viewing 15 replies - 1 through 15 (of 24 total)
  • The topic ‘How to do a miniblog…’ is closed to new replies.