Mimbo is a great magazine theme. It is easy to manipulate, the CSS is clearly written, and there are so many uses for it.
For an example of a site that uses the Mimbo theme, look at The Brown Spectator. The Spectator has modified the Mimbo theme to fit its own needs, which is skill you’re about to learn. This theme is pretty neat in that it uses arrays to display data. This means that the code for Mimbo is incredibly clean, which makes for easy modifications. Let’s take a look at the front page’s file, the Main Index Template or index.php
Okay, this is just retrieving the header.php file listed as header in the WordPress theme editor. We’ll worry about that file later.
This snippet of coding looks for all posts in category 3 and then displays 1. The problem with this methodology is that WordPress doesn’t allow you to know really easily which category is cat=3. There are ways, but if you don’t know how, an easier way to display something in my humble opinion, is to use category names. To do this delete cat=3 from the code snippet and replace it with category_name=the name of the category you want displayed.
I think this is pretty obvious, but since I’m assuming people reading this are noobs like I was, I’ll take nothing for granted. If you want more posts displayed, change showposts=1 to showposts=whatever number posts you want displayed
The final part of the code is the beginning of a loop that displays what you just asked it to display. Basically, it just says that while there is still a post to display in the category deliniated, execute the loop.
This code snippet represents what makes WordPress so incredibly powerful. Custom values are a coder’s best friend as they allow you to customize wordpress in any way you want: show pictures, display posts or alternative CSS, or any other creative thing you can think of.
In WordPress, when the_permalink() appears within a loop that is retrieving posts, it will print the URL address of the post. Likewise, the_title() will print the title of the post being retrieved. The code snippet bloginfo(’template_url’), will print the URL of the file your template is located: www.X.com/wp-content/themes/YOUR_THEME’S_NAME. As a string, bloginfo is one of the most versatile and useful that WordPress has to offer.
(Most of this was synthesized from the WordPress website)
In this particular code-bit, however, the bloginfo(’template_url’) code is wrapped in a img src= code snippet and followed by a /images/ another bit of code which I’ll explain in a second. Anyhow, what it all means is that there is an images folder in the directory where the theme is located. The location of the image itself and the type of image (jpeg, gif, png) is specified by a custom value.
Now, as I said, custom values are pretty cool. But there are plenty of great blog posts on how to use them online. I’m concerned specifically with the Mimbo template. Sometimes when I’ve posted columns, there aren’t coinciding pictures. Mimbo’s way of handling this is to give a dummy location for an image that doesn’t exist. This renders on firefox as a little box with nothing in it, and in Internet explorer, this renders as one of those giant broken file images we all love so much. So here’s how you deal with that.
You flip things around a bit. The original Mimbo code is a bit backwards. It assigns the location of the image to a variable before it checks to see if there is even an image in existence. In this example, however, the variable is assigned the value in the string get_post_custom_value(). And then, it checks to see if the value is empty. If it is empty, then it knows to skip putting in the picture, however, if the value comes back with something in it, then it knows to put a picture next to the title. Problem solved.
Just like the comment says. This is where the name of the Lead Story’s category gets printed. It gets printed in between h3 tags. Usually, when I implement Mimbo, I remove this portion of code for the lead story. The story is at the top of the page, and I generally just let it sit there. It’s pretty obvious that it’s the lead story, the category doesn’t matter so much, in my opinion. Once again, you can see an example of this on The Brown Spectator’s website.
This simply adds a link to the lead story. You can change the title of the link, if you want to, by changing the_title(). But why would you want to?
This code snippet prints an excerpt of your lead story right below the title that was printed in the previous snippet. And then, right after the excerpt is printed, the there is a link that is added that looks like {More»}. Sometimes, people don’t like the snippets at the end that link to the article. In case you’re wondering, it’s safe to delete from “{<a href=”<?php
the_permalink() ?>”… to …”More»</a>}”.
<div id=”leftcol”>
<?php
// this is where the Features module begins
query_posts(’showposts=3&cat=4′); ?>
<h3><?php
// this is where the name of the
Features category gets printed
wp_list_categories(’include=4&title_li=&style=none’);
?></h3>
<?php while (have_posts()) :
the_post(); ?>
<div
class=”feature”><a href=”<?php the_permalink()
?>” rel=”bookmark” title=”Permanent Link to <?php
the_title(); ?>”><img src=”<?php
bloginfo(’template_url’); ?>/images/<?php
// this is where the custom field prints images for each
Feature
$values =
get_post_custom_values(”Image”); echo $values[0]; ?>” alt=”"
/></a><a href=”<?php the_permalink()
?>” rel=”bookmark” class=”title”>
<?php
// this is where title of the Feature gets printed
the_title();
?>»</a></div>
<?php endwhile; ?>
</div><!–END LEFTCOL–>
<div id=”rightcol”>
<?php
// this is where you enter the IDs of which categories you want to
display
$display_categories = array(5,6,7);
foreach ($display_categories as $category) { ?>
<div class=”clearfloat”>
<?php
query_posts(”showposts=1&cat=$category”);
$wp_query->is_category = false;
$wp_query->is_archive = false;
$wp_query->is_home = true;
?>
<h3><a href=”<?php echo
get_category_link($category);?>”><?php
// this is where the name of each
category gets printed
single_cat_title();
?></a></h3>
<?php while
(have_posts()) : the_post(); ?>
<?php
// this grabs the image filename
$values =
get_post_custom_values(”Image”);
// this checks to see if an image file exists
if (isset($values[0]))
{
?>
<a
href=”<?php the_permalink() ?>” rel=”bookmark”
title=”Permanent Link to <?php the_title();
?>”><img src=”<?php
bloginfo(’template_url’); ?>/images/<?php $values =
get_post_custom_values(”Image”); echo $values[0]; ?>” alt=”"
/></a>
<?php }
?>
<a
href=”<?php the_permalink() ?>” rel=”bookmark”
class=”title”><?php
// this is where title of the article gets printed
the_title();
?>»</a>
<?php
the_excerpt(); ?>
<?php
endwhile; ?>
</div>
<?php } ?>
</div><!–END RIGHTCOL–>
</div><!–END CONTENT–>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
thanks for posting this! It was really helpful that you didn’t skip over the ‘obvious’ stuff ;)
Comment by rad_thundercat — May 9, 2008 @ 3:14 pm
I have been working with the Mimbo theme for a day or so, and the most obvious problem is with the lead story/featured/category headers and the image capabilities. Having to ftp images to your site for use with articles is pretty bad, and I have been able to bypass this with some PHP code however, its still not fullproof and I am trying to come up with a better way to integrate WP 2.5’s media library to allow a user who has an image at the top of the “lead story” post, to appear as the image on the home page.
If anyone has an idea, I would love to hear it. So far I am running into complications in trying to dynamically pull and image out of a post and use it on the home page as the placement image for the lead article for example.
Comment by Steve — June 19, 2008 @ 1:21 pm
Steve, I’m not sure if this is exactly what your looking for (and I’ll confess I’ve never actually used this plugin). But, I think what it’s supposed to do is pull the first image you use in a post and put it on the frontpage. It’ll probably require some tweaking to be integrated into the Mimbo theme, but it sounds like it might be what you need.
Comment by Joshua Unseth — June 24, 2008 @ 4:19 am