We keep up on the newest technologies and write about it every chance we can get. Feel free to browse.

Developing A Wordpress Magazine Theme – Part One

Posted: April 16th, 2009 | Author: Bryan | Filed under: Tutorial | 2 Comments »

This tutorial is going to teach you how to build some of the functionalities that are commonly found in magazine style themes. I am going to stick with pretty generic concepts as the pertain to Wordpress only. And mind you, I will not be teaching you how to build an entire theme from scratch, we’ll just focus on building the homepage with the classic magazine theme functionality.

Recent Posts Boxes Image Preview

A common feature in a Magazine theme is those 1/3 columns with thumbnails of an image in the post. The CSS is actually pretty easy, we’ll just divide the width of the total area into three sections. Let’s make it easy and say its 960px wide, so we have 3 boxes with a width of 320px each. Let’s also make them square, and they need to float to the left to stack horizontally. This is the ideal HTML and CSS:

Demo Feature Box
  1. <div class="featuredbox">
  2.  <img src="/image1.jpg" alt="this is a thumbnail" width="128" height="128" />
  3.   <h3><a href="#">Heading 1</a></h3>
  4.   <p>Post excerpt here orem blah blah….</p>
  5.  <a href="#">Read more…</a></div>
  6. <div class="featuredbox">
  7.  <img src="/image2.jpg" alt="this is a thumbnail" width="128" height="128" />
  8.   <h3><a href="#">Heading 2</a></h3>
  9.   <p>Post excerpt here orem blah blah….</p>
  10.  <a href="#">Read more…</a></div>
  11. <div class="featuredbox">
  12.  <img src="/image3.jpg" alt="this is a thumbnail" width="128" height="128" />
  13.   <h3><a href="#">Heading 3</a></h3>
  14.   <p>Post excerpt here orem blah blah….</p>
  15.  <a href="#">Read more…</a></div>
  1. .featured {
  2.   width:320px;
  3.   height:320px;
  4.   float:left;
  5. }
  6. .featured img {
  7.   float:left;
  8. }

This should pretty much prep us for what we want to do, let’s make the WP_Query to grab this data. There is obviously no use in repeating ourselves like we did with the HTML with PHP at hand, in fact, lets just use a standard loop, like this:

  1. <?php $featured = new WP_Query("showposts=3");
  2.   while($featured->have_posts()) : $featured->the_post();?>
  3.   <div class="featuredbox">
  4.    <img src="/imagenum.jpg" alt="this is a thumbnail" width="128" height="128" />
  5.     <h3><a href="#">Heading Num</a></h3>
  6.     <p>Post excerpt here orem blah blah….</p>
  7.    <a href="#">Read more…</a>
  8.   </div>
  9. <?php endwhile; ?>

Well that’s close, but let’s get those standard Wordpress tags in there, otherwise they’ll be uselessly looping on a worthless box, with no appropriate content gracing our Wordpress magazine theme. Let’s try:

  1. <?php $featured = new WP_Query("showposts=3");
  2.   while($featured->have_posts()) : $featured->the_post();?>
  3.   <div class="featuredbox">
  4.    <img src="/imagenum.jpg" alt="this is a thumbnail" width="128" height="128" />
  5.     <h3><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3>
  6.     <?php the_excerpt(); ?>
  7.    <a href="<?php the_permalink() ?>">Read more…</a>
  8.   </div>
  9. <?php endwhile; ?>

That’s much closer, however, we’re missing our thumbnail. Let’s make this simple, we can get fancier but this technique works well for new blogs. If you’re moving your blog, this type of Wordpress magazine theme might not be right. You’ll want to go into your Wordpress Settings->Media section and set the thumbnail dimensions to 128×128 (or whatever you set it to) and check the crop checkbox.

  1. <?php
  2.  
  3.   function match($regex, $str, $i = 0) {
  4.    if(preg_match($regex, $str, $match) == 1)
  5.     return $match[$i];
  6.    else
  7.     return false;
  8.   }
  9.  
  10.   $featured = new WP_Query("showposts=3");
  11.   while($featured->have_posts()) : $featured->the_post();
  12.  
  13.   ob_start();
  14.   the_content();
  15.   $imgBeg = strpos(ob_get_contents(), '<img');
  16.   $imgStuff = substr(ob_get_contents(), $imgBeg);
  17.   ob_end_clean();
  18.   $imgEnd = strpos($imgStuff, '>');
  19.   $postImg = substr($imgStuff, 0, $imgEnd+1);
  20.   $postImg = match('/src="(.*?)" /msi', $postImg, 1);
  21.   $postImg = preg_replace('/.jpg/','-128×128.jpg', ob_get_contents());
  22.   $postImg = preg_replace('/.png/','-128×128.png', ob_get_contents());
  23.   $postImg = preg_replace('/.gif/','-128×128.gif', ob_get_contents());
  24.  
  25. ?>
  26.   <div class="featuredbox">
  27.    <img src="<?php echo $postImg; ?>" alt="<?php the_title(); ?>" width="128" height="128" />
  28.     <h3><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3>
  29.     <?php the_excerpt(); ?>
  30.    <a href="<?php the_permalink() ?>">Read more…</a>
  31.   </div>
  32. <?php endwhile; ?>

This code grabs the first image URL, adds the -128×128.jpg to the end of the file name, calling the file created by Wordpress when you upload the image originally.

You can explore some more options for the WP_Query by browsing the official Wordpress site. You can select only certain categories, and go off of other more choosy criteria. Whatever you do, tune in for the next edition.


Our Special Wordpress Theme

Posted: November 2nd, 2008 | Author: Bryan | Filed under: Analytics, General, Open Source, Tutorial | 74 Comments »

If you’d like some customization done on the theme, I highly recommend going to our sister site GazelleThemes.com for an awesome and affordable Pro Package for Clean Home. Right off the bat, this has blurb customizations, new color schemes and an improved design (not to mention full customization support)! Unfortunately, due to time constraints, we cannot help users with the free-use GPL theme you’ll find on Wordpress.org.

Today marks a big day for us, we’ve released the same custom theme that cloaks this very site! Well, it is a very heavily modified version of this theme, but it retains the style that we’ve got going on. I am rather partial to my minimalism themes (just check out my personal site) but this way it remains clean and sparkly.

Without further ado, I present Clean Home (v 1.2.1), our house theme. You can download it for free now right here. So what’s special about this theme? Let me list the ways:

  • Lightweight - A grand total of two images, both 2×6. The rest is XHTML and CSS.
  • Minimalistic - No more distracting of your users, with our theme, your content stays king.
  • Attention Grabbing - With a semi-customizable (1.1.3) blurb, you can say something right away that people just have to read.
  • Full Widget Support - I even took care of some all (1.1.3) of the standard widgets’ CSS for you.
  • Valid XHTML and CSS - As long as you stay valid on your end… :-)
  • GPL License – New! – Do what you will with the theme!
  • Multiple Widget – Now with three sidebars (1.1.4) for maximum customization: top navigation, blurb, and sidebar.
  • (Pro) Fully customizable blurb - select between hidden, random phrase, image, and per-post assigned text.
  • (Pro) Adsense - three separate locations for Adsense integration.
  • (Pro) Color selection - Over 7 color schemes.
  • (Pro) Style selection - 2 distinct styles, selectable from inside the options.
  • (Pro) Feedburner integration - an email subscribe button plus automatic feed redirection.
  • (Pro) Fully customizable Home Page - select different categories and how many articles to showcase!

If you’d like some common custom options, visit our sister site Gazelle Themes for cheap purchasing options for the Pro Package. Otherwise, this is just our way of giving back to the wonderful open source community that makes our business possible.

Go ahead and download it now! Feel free to let us know what you think in the comments! Enjoy!

Check out our home page for any Missouri Web Design help you may need!


jQuery AJAX Contact Form

Posted: October 5th, 2008 | Author: Bryan | Filed under: Coding, Tutorial | 67 Comments »

Today I am going to speak a little bit about a quick and easy way to make a jQuery AJAX Contact Form that employs a honeypot to foil pesky email bots. You can also check out the demo here to get an idea of how the end product will act. You can use the form anywhere you like, but a courtesy link somewhere is appreciated. It is released under the Creative Commons Attribution License. Let’s rundown the goals:

  • A safe form with sanitation.
  • Load success or error messages dynamically without leaving the page.
  • Descriptive error messages detailing why the entered values failed validation.
  • A honeypot to beat the bots.

That may sound like quite a tall order, but in fact, it can be put together fairly quickly with the tools that are available online. If you don’t feel like learning about how to create a form and just want the form. Go ahead and download it here, be sure to change the html to sendmail.php and the email address in the same file. Other wise, read on!

Read the rest of this entry »