January is Theme Month

In January 2009 I will be concentrating on themes and themeing.

Got a theme question, or conundrum? Let me know.

Friday Fun: I can has code?

What is the one thing that WordPress really needs to compete with enterprise level CMS systems? You got it, LOLCODE.

In a moment of inspiration this afternoon I decided to take a PHP LOLCODE parser and a WordPress plugin and combine them.

I can has lolcode, the plugin, when turned on, will parse your post content and widget text for LOLCODE and run it.

For example:

lolcode

Will output

loloutput

You can download the I Can Has LolCode WordPress plugin here.

Fun with Theme Widgets

Following on from my post about Widget Management Concepts, I have produced a new plugin with the aim of making it super easy to include widgets within themes without needing to be concerned with writing plugins, or code in functions.php.

Installation

To install the plugin just download it and activate it. It has no options.

Creating Theme Widgets

Creating a theme widget really is very easy. Here is a step by step process.

Step 1

Create a new PHP file in the theme and call it {something}.widget.php.

Step 2

Add a PHP comment at the top of the file to indicate the name and description of the widget. Like this:

<?php
/*
Widget Name: 3 Random Posts
Widget Description: Outputs 3 random posts in a list
*/
?>

Step 3

Add the code you want for your widget. In this example I am adding code to output three posts at random:

<?php $postslist = get_posts('numberposts=3&order=ASC&orderby=rand'); ?>
 
<ul>
<?php foreach ($postslist as $post) : ?>
	<?php setup_postdata($post); ?>
	<li>
	<strong><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></strong><br/>
	<?php the_excerpt(); ?>
	</li>
 <?php endforeach; ?>
</ul>

Note that this code is identical to the code you would insert into a theme file to do this manually. There is nothing special about this code that needs to be changed to make it a widget.

Step 4

Assign the widget to sidebar.

workingwidget

On the left of the image is the output (there is only one post because it is a fresh installation) on the right the widget added to the sidebar.

Download

You can download the plugin from WordPress extend.

The Potential

I think that making it this easy to create, and more importantly understand, the widgets included with a theme opens up a lot of possibilities. For example, with this it would be easy to use a sidebar and widgets to offer different layouts for a featured post on the home page.

If you have any suggestions for improvements to the plugin itself, or ideas about how it can be used, let me know.

Fun without Cliches

Fun Without Cliches is a quick and simple plugin to help you check whether you have fallen back into the same tired old cliches when you write.

The plugin checks a list of cliches — based on this list — against the content when a post is viewed in draft and highlights any cliches a ghastly pink colour. For example:

cliches with highlighted pink backgrounds

You can download the plugin from WordPress extend.

I haven’t had much time to check the list so if there is anything in particular that you think should be added, changed, or removed, let me know.

Shortcode URLs in your posts

Not too long ago I was in the situation where I needed to move my photoblog to a new domain. But there was a problem, I needed to convert every image URL from one domain to another. The same needed doing for the hyperlinks as well.

That problem is now gone thanks to Peter who has written a plugin that uses the WordPress shorcodes API to insert the blog URL so now your links will change automatically.

Its a great idea and might well save your hours of trouble at some point in the future.

 Page 1 of 2  1  2 »