Art, Craft and Sculpture Fair at Hylands Park

This weekend Hylands Park hosted an Art, Craft and Sculpture fair. Unlike other fairs I’ve been to recently, I was really impressed. There were multiple tents with lots of different craft demonstrations. See below some pics of my favourites.

I think the most impressive of all the crafts I saw at the fair had to be this one. Paul Hornby delicately cuts away at old coins to create intricate jewellery. It was just fascinating to watch.

Another of my favourites was Martin Green and his Victorian circular knitting machine. With the twirl of a handle the machine quickly churned out meters of knitting. Its fascinating to see old machinery preserved and still in use today.

The guys from Stokes of England gave me an excellent demonstration of heating up iron and shaping it on the anvil.

I loved seeing the wood carvers with their chain saws carving away at big chunks of wood. It really is a great skill to be able to carve using a chain saw, you would think that you would struggle to get such precision.

WordPress Custom Post and Custom Taxonomy Permalinks

I have the following setup:
– A custom post type called Products.
– A custom taxonomy called Product Categories.
– A page called Products with a custom page template assigned to it. This page template allows me to query my custom posts and display them in a layout of my choosing. Slug is set to /products.

I wanted my urls for my products to display in the following way:

Or to be more specific:
– View my “Products” page set with the custom template at the url /products
– View each “Product Category” on a url of /products/product-category
– View my custom post type “Products” on a url of /products/product-category/product-name

But nothings ever easy. The trouble I was having was that both my product page and product post type wanted to use the same slug (/products) and therefore conflicted causing 404’s. Not only that but custom taxonomies by default do not show the category in the url, and finally although in my head it made sense as a user to see the url /products/product-category/product-name they were not in any kind of heirarchical structure within wordpress to order them in a url this way.

So after a lot of googling and after finding this really helpful article I finally managed to put together some code that fixed the problem.

add_action( 'init', 'register_custom_post_types' );
//Set up Product Post Type
function register_custom_post_types() {
	register_post_type('products', array(
		'label' => __('Products'),
		'singular_label' => __('Product'),
		'public' => true,
		'show_ui' => true,
		'capability_type' => 'post',
		'hierarchical' => true,
		'rewrite' => array( 'slug' => 'products/%productcats%' ),
		'publicly_queryable' => true,
		'query_var' => true,
		'has_archive' => true,
		'supports' => array('title','editor','thumbnail','excerpt'),
        //Set up Product Categories
	register_taxonomy('productcats', 'products', array(
		'hierarchical' => true,
		'label' => 'Categories',
		'singular_label' => 'Category',
		'rewrite' => array( 'slug' => 'products' ),
//Fix Permalinks
add_filter('post_link', 'product_permalink', 10, 3);
add_filter('post_type_link', 'product_permalink', 10, 3);
function product_permalink($permalink, $post_id, $leavename) {
	if (strpos($permalink, '%productcats%') === FALSE) return $permalink;
		// Posts
		$post = get_post($post_id);
		if (!$post) return $permalink;
		// Custom Taxonomy
		$terms = wp_get_object_terms($post->ID, 'productcats');
		if (!is_wp_error($terms) && !empty($terms) && is_object($terms[0])) $taxonomy_slug = $terms[0]->slug;
		else $taxonomy_slug = 'uncategorized';
	return str_replace('%productcats%', $taxonomy_slug, $permalink);
//Flush permalinks
flush_rewrite_rules( false );

For a step by step explanation of the permalink function please refer to the original article I found on google. You may find you need to go to settings/permalinks in your admin and save again for the changes to take effect. You will already need to have the custom permalink structure set to /%postname%. More information on setting up custom page templates, custom post types and custom taxonomies can be found on the wordpress codex.

30 Days of Creativity

I have decided to participate in 30 Days of Creativity. Its a great idea to get the social community creating and sharing every day for the whole month of June. Unfortunately Ive come across this little challenge a week in, so I am a little behind. But hey its better late than never. I plan to publish my daily creations as a weekly installment so stay posted 🙂

Learning JQuery

Over the past year I have been considerably brushing up on my JQuery skills. I thought I would take this opportunity to give a few pointers to others who may be a little nervous about taking their first JQuery steps.

1. Debugging
The best thing I learnt was how to use console.log() in firebug.
console.log() is great way of checking your code as you go. Its far less annoying than using alert() because you can see what is going on behind the scenes without nasty popups to keep closing.
You can use it to check that the selectors you are targeting are correct or that the script you are including has been included correctly.

2. Reading
A really friendly book to get you started is JQuery from Novice to Ninja by sitepoint. Its really easy to understand and has some nice tutorials to get you going.

3. Making use of JQuery documentation
Pretty much all you need to know is on the JQuery official site. Take some time to look around and understand the difference between events, selectors and traversing. Once you know how it all fits together its easy to reference whatever you need. All docs have real source code examples too.

4. Comment your code
It goes without saying that commenting your code whatever language, is good practice. It not only helps you but everyone when maintaining code in the future.

Whilst learning, I think it is a good idea to comment as much as possible. I found that I might copy and paste some code from somewhere (not necessarily the best approach I have to say but it does start to make you more familiar with seeing JQuery) and then modify it to fit what I needed. Its really easy in the early days of learning JQuery to do this and then forget later why or what is going on. Simple commenting of each line of code in laymans terms forces you to learn and understand what the code is actually doing.

5. Write it down before hand
A colleague of mine told me to do this so many times. If you write down what you want to achieve in simple terms on a piece of paper it helps you break down a daunting task into more manageable chunks. e.g click the button, fade in the div etc

A few good tutorial/reference sites:

50 JQuery Snippets
JQuery Videos
JQuery for Designers

WordPress to end support for IE 6

I’ve just been checking out the release notes for the upcoming WordPress 3.2 and it came to my attention that they will  no longer be providing support for IE6. Yippeeeee!

It would seem that the argument for dropping support for IE6 is starting to have some real weight behind it. With WordPress following in the footsteps of many other big names over the last 18 months including Google, YouTube and finally Microsoft themselves it looks like the task of convincing clients to apply the method of graceful degradation is going to become a much easier task.

Jack Frost came to visit!

Everything seemed to be going so well. My tomatoes and runner beans were dominating my cold frames and what with peppers, chillies, aubergines and cucumbers all demanding room, I decided to take a calculated risk and plant some outside. After all it has been the hottest April on record.

But the calculated risk didn’t pay off… 2 days after planting them out and only a few weeks after sun damage. Frost sneaked up on me and claimed them. So I thought I’d share a pic or two of what frost damage looks like. Guess I need to exercise a little more patience and wait a few more weeks before planting any more out.

Tomatoes on the left, Runner Beans on the right.

Attempt #1 at growing an Avocado Tree

England doesnt exactly have the ideal climate for growing an Avocado tree. However i’ve been assured by several articles that it is possible to get one to grow here, it just takes a little patience… upto 10 years apparently!!

So armed with a little advice, i’ve selected 1 of the 3 listed methods of getting an Avocado seed to germinate.

“leave the seed in direct sunlight until it starts to split. Then pot it up”

Sounds simple enough.. lets see how it goes!

Mini Rhubarb Pies

Courtesy of my colleague David for the recipe and my neighbour for the rhubarb, I tried out a new recipe this weekend. Its very easy to make and super tasty too.


100g of butter
100g of caster sugar
4 egg yolks
250g of plain flour
1tsp of baking powder

1. Cream the butter and sugar together.
2. Add one egg yolk at a time until its all mixed in together
3. Add the flour a litte at a time until its all mixed together and a smooth pastry is formed.
4. Roll out the pastry and place in a greased muffin tin. (Makes approx 18-20 small pies)

600g of uncooked rhubarb cut into small pieces
60g of corn flour
4 egg whites
200g caster sugar

1. Mix the chopped rhubarb with the cornflour.
2. Whisk the egg whites together until you can form soft peaks.
3. Gradually add the sugar into the egg whites.
4. Fold the rhubarb into the egg whites and sugar mix.

Place the meringue mixture into the pastry cases. Cook for 20mins at 170

WordPress Comments Form – How to change HTML

I searched high and low for a good tutorial on how to change the HTML of the wordpress comment form. From the articles I did find I managed to put together something that works. Feel free to post a comment if there is a better way of doing this…

I put the below code in functions.php and comment_form(); in my comments.php

The code below is my modified version. For defaults simply add or replace my code with

add_filter( 'comment_form_defaults', 'my_comment_defaults');
function my_comment_defaults($defaults) {
	$req = get_option( 'require_name_email' );
	$aria_req = ( $req ? " aria-required='true'" : '' );
	$defaults = array(
		'fields'        	   => array(
		'author' => '<div><label for="author">' . __( 'Name' ) . ( $req ? '<span class="required">*</span>' : '' ) . '</label> ' . '<input id="author" name="author" placeholder="your name" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></div>',
		'email' => '<div><label for="email">' . __( 'Email' )  . ( $req ? '<span class="required">*</span>' : '' ) . '</label> ' . '<input id="email" name="email" placeholder="" type="email" value="' . esc_attr(  $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></div>'
		'comment_field' => '<div><label for="comment">' . _x( 'Comment', 'noun' ) . '</label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"  placeholder="your comment"></textarea></div>',
		'must_log_in'          => '<p class="must-log-in">' .  sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>',
		'logged_in_as'         => '<p class="logged-in-as">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>' ), admin_url( 'profile.php' ), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>',
		'comment_notes_before' => '<fieldset>',
		'comment_notes_after'  => '</fieldset>',
		'id_form'              => 'commentform',
		'id_submit'            => 'submit',
		'title_reply'          => __( 'Leave a Comment' ),
		'title_reply_to'       => __( 'Leave a Reply %s' ),
		'cancel_reply_link'    => __( 'Cancel reply' ),
		'label_submit'         => __( 'Comment' ),
    return $defaults;

You will notice I have made the following modifications

  • Removed the website field
  • Added type=”email” to the Email field (HTML5)
  • Added placeholder text (HTML5)
  • Removed the default text from the top and bottom of the form and replaced with <fieldset></fieldset>
  • Moved the required * inside the label
  • Changed the “Leave a Reply” title to “Leave a Comment”
  • Changed the text of the submit button