Taking Advantage of Functions.php in WordPress Themes

— WordPress themes can optionally use a file where theme developers can add their own functions. This file acts like a plugin and gets automatically loaded during WordPress initialization, to get it working it just has to be named functions.php and reside in the theme folder.

Although not many themes seem to use it, it’s very powerful, you can use the functions inside for anything you choose. For me it helps me to define a library I can reuse to fasten up my work while keeping code clean and easy to manage. For example I have functions to list recent posts, easily display a copyright footer, highlight author comment, shorten text etc.

I have uploaded some of these functions I use as an example for you to download and try. To use them drop functions.php file in your theme folder.

→ Download the functions here

› Continue reading

Tags: , , ,

Thursday, October 23rd, 2008 WordPress 45 Comments

ScrnshotsRSS: Scrnshots.com Plugin For WordPress

— This plugin for WordPress allows you to show Scrnshots.com captures on your sites. It’s based on the great flicrkRSS plugin by Dave Kellam and is very easy to setup and configure via an admin panel. The plugin also has cache support, allowing you to save thumbnails on your own server.

→ Download ScrnshotsRSS plugin for wordpress here

Installation

  1. Put scrnshotsrss.php in your plugins directory.
  2. Activate the plugin.
  3. Configure your scrnshotsRSS options under the Settings tab.
  4. To use an image cache, create a writable directory and specify its location in the settings.
  5. Add to your theme where you want the images to appear ( or use the widget system ):
    < ?php get_scrnshotsRSS(); ?>
    

› Continue reading

Tags: ,

Wednesday, October 8th, 2008 WordPress 25 Comments

Manipulate images from WordPress post’s content with Regular Expressions

— A couple of months ago I got requested to deliver a website that would let the client publish online brochures. These brochures featured image slideshows with a description text, tags, categories etc. Many of us use WordPress not only as a blog platform but also as a multifaceted CMS. There are many features WordPress give that go beyond the blog format and that with the right adjustments and/or plugins, can be used to provide a complete solid solution. Thats why we choose to build this up on WordPress.

At first I look around to see the wp plugins available but found that none of them suited the needs of this project. I wanted to keep this very simple and easy for the client, so the best solution I came up was to let client dump any image he wanted in the post’s content-box and deal with it later with regular expressions. This way I could manage the content and present it in a good looking slideshow I could style myself.

It didn’t took much time to do it once I figured out what I wanted it to do as it’s simple PHP code:


// Start the Loop
< ?php if (have_posts()) : ?>< ?php while (have_posts()) : the_post(); ?>

< ?php
// Set the post content to a variable
$szPostContent = $post->post_content;

// Define the pattern to search
$szSearchPattern = '~<img [^\/>]*\ />~';

// Run preg_match_all to grab all the images and save the results in $aPics
preg_match_all( $szSearchPattern, $szPostContent, $aPics );

// Count the results
 $iNumberOfPics = count($aPics[0]);

// Check to see if we have at least 1 image
if ( $iNumberOfPics > 0 )
{

     // Now here you would do whatever you need to do with the images
     // For this example I'm just going to echo them
     for ( $i=0; $i < $iNumberOfPics ; $i++ )
     {
          echo $aPics[0][$i];
     };

};

// ...finish the loop, etc

› Continue reading

Tags: , , ,

Tuesday, October 7th, 2008 WordPress 30 Comments
« Previous Entries Next Entries »

About Me

Matt Varone - Matias Varone - sksmatt
HI there,

I'm a freelance creative web developer, UI designer and hobbyist musician.

Twitter Status

Flickr Gallery

    Blue WallClutter drawerCS4 Replacement iconsCS4 Replacement icons