Category: Blog

Red Lodge Conservation Group

20130122-220026.jpgLately I’ve been working with the conservation group in a local village. They were awarded Big Lottery funding for promoting and growing the group, and decided a website was an ideal partner to traditional leaflets. A local designer was contracted to design the print media and I built the web site around the identity he created. It will be launching over the next two weeks but here’s a sneak peak.
Continue reading “Red Lodge Conservation Group”

Resolving wpautop and Shortcode problems


WordPress offers quite a friendly hybrid WYSIWYG / HTML editor that makes publishing easy even for those with no HTML experience. One of the ways it accomplishes this is through a function called wpautop. This runs on the_content as the page is drawn to insert <p> and <br/> tags as needed. By inserting them dynamically like this it prevents code creeping in to the editor and leading to potential confusion / corruption. However, it can sometimes lead to unexpected results – especially when combined with shortcodes.
Continue reading “Resolving wpautop and Shortcode problems”

Responsive Tables with CSS and jQuery

One of the big problems with Responsive Web Design is dealing with fixed size elements, especially iFrames and Tables. While a table can be flexible, there will also be a minimum size past which it will spill out of it’s container or be cropped/trigger scrolling, depending on your CSS setup.

Whilst working on a site recently I started looking for a solution and came across a good round up of responsive table techniques by Chris Coyier. There are no perfect solutions, and each of the techniques there have pros and cons depending on your exact design. From a UX perspective I think Chris’ technique displaying a table as a list using pseudo elements is great – however when non-code-savvy editors will be creating your content, you can’t expect them to create custom CSS or add unusual variables to the table HTML. In the end I decided the most versatile was the second solution created by Scott Jehl that shrinks the table using CSS below a @media-query defined break and allows you to view it as an overlay. One big problem with this implementation is cross browser compatibility – there isn’t a lot of it…
Continue reading “Responsive Tables with CSS and jQuery”

Advanced CPT Filtering in WordPress

Prior to WordPress 3.1 you could only use one meta_key : meta_value : meta_compare in a query_posts. This meant that you could, for example, get the custom post type (cpt) product, filter it to get only those products that have a price >= 100. However you could not then orderby department ASC. Neither could you get the products with a price over 100 and colour green.
Now you can do advanced CPT filtering in WordPress since 3.1 with meta_query. There’s a nice intro post to this which I won’t repeat, but here is the code I used last week as an example:
Continue reading “Advanced CPT Filtering in WordPress”

UK GovCamp 2012 in review

UK GovCamp 2012 official logo
As mentioned on Thursday, Friday was the 5th UK GovCamp and the biggest yet.

The day started well (with free t-shirts and lots of tea/coffee & biscuits), and even 260 people introducing themselves to the room was kept on schedule. You can see the agenda agreed on Flickr courtesy of David Pearson.
There was a definite social media theme (managing it, measuring ROI, best practices, safety, custom internal social networks etc), but also sessions covering a huge variety of topics, both practical and theoretical.
Continue reading “UK GovCamp 2012 in review”

Heading to UKGovCamp2012

Tomorrow I will be getting up at silly o’clock to drive to Cambridge, park, walk 2 miles to the station, train to Kings Cross, tube to Victoria and a walk to Microsofts UK HQ. It’ll take about 3.5 hours, but, based on the reports from last year, worth every minute.
UK GovCamp 2012 official logo
This will be my first year attending UKGovCamp (read more about UKGovCamp here), and also my first “unconference“. From the pre-event chatter on Twitter (#ukgc12), Facebook/ukgovcamp and the official site there are going to be some excellent sessions covering a huge range of topics related to digital / IT in the Public Sector.

If this sounds interesting you can “listen in” on the day and after on the UKGovCamp12 Buzz page, including a livestream and liveblog of the first session. I’ll also be posting a followup after the event, and possible during as well.

On a related note I just picked up a pair of Goldring NS1000 active noise cancelling headphones and I’m looking forward to giving them their first real test on the journey to and from London.

Highlighting Custom Post Types in the menu

There seems to be a problem/oversight in WordPress at the moment (afaik).

You can generate Custom Post Types (CTP) easily enough, and have them visible on any page using templates/the loop, but when you click through to a single CTP WordPress assigns the current_page_parent to the default posts page. For many that will mean highlighting the News or Blog pages of their site.
After a lot of searching, and finding lots of people asking the same question but no solutions (except hacks), I found a reply by jonny_williams to a post about this on the forum. His solution at least runs from functions.php (and so before the content is displayed) rather than being accomplished through javascript like many others.

After a couple of modifications I settled on this:

function fix_portfolio_parent($menu){
	global $post;
	if ( 'projects' == get_post_type() )
		$menu = str_replace( 'current_page_parent', '', $menu ); // remove all current_page_parent classes
		$menu = str_replace( 'menu-item-XXX', 'current_page_parent menu-item-XXX', $menu ); // add the current_page_parent class to the page you want
	return $menu;
add_filter( 'nav_menu_css_class', 'fix_portfolio_parent', 0 );

Just replace the XXX with the number of the parent page you want to highlight, and 'projects' with the name of your CTP. As always, make sure you function name is unique and relevant. If you have multiple CTPs, either duplicate this for each, or extend the if (I haven’t looked at the performance differences of these options).

Conditionally loading plugin scripts in WordPress

I’m a big fan of WordPress – it’s both easy to use as an author and easy to develop for. There are also a huge amount of free (and paid) plugins to extend the core functionality.
Unfortunately there is a downside – most plugins do not conditionally load their files only on pages that call them. It is all to easy to end up with every page loading a string of Javascript and CSS files slowing the site to a crawl, when they are only actually required on specific pages.

I’m going to show 2 quick examples of how to use the functions.php file in your theme to only load the scripts for a plugin on a specific page using deregister and remove_filter, which are built into WordPress.
Continue reading “Conditionally loading plugin scripts in WordPress”

York House photoshoot

Last weekend I had the pleasure of staying at York House in Tetbury. While they won’t be opening until spring 2012 – just in time for the Gold Cup – this boutique bed & breakfast was ready for it’s first photoshoot. After spending an evening with the proprietor Brock Bergius discussing plans for the website and how to reflect the ethos, the morning saw us dressing the rooms and getting down to the photos. With work still going on to get the guest rooms ready we focussed on the communal areas and the little details that really show the character of the house.
It’ll be exciting to see York House develop over the next couple of months and we should be launching the website shortly to let potential customers keep up to date on the progress. If you’re planning a visit to the Cotswolds for a holiday or are looking for somewhere to stay for the Cheltenham festival & Gold Cup, York House in Tetbury should be on your list!

For now – here’s a sneak peak at what York House will offer:

Tracking downloads in Google Analytics with jQuery

Google Analytics (and other similar services) aren’t 100% reliable, but they give a valuable insight into what the visitors to your site are up to. One thing they won’t do is track clicks on download links, unless you specify an onClick action for each link.

But here jQuery comes to the rescue – just a few lines of code will have all links to whatever filetypes you need tracked in Google Analytics as Events. Another common use of the same technique (with a few minor changes to the code) is to track clicks on outgoing links.
Continue reading “Tracking downloads in Google Analytics with jQuery”