Thats why my Mac keeps going to sleep!

Only just realised why my MBA keeps going to sleep on my lap while I am working in front of the TV. My iPhone 6 in my pocket! The magnet in the case is interfering with the Hall Effect switch on the left hand side of the body of the Mac. There is a simple fix though. Took me ages to work it out and implement it properly.

Take the phone out of your pocket, and remember, you need to do this each time you sit down to work on your sofa!

internets, web dev, WordPress

Redirect category images to external site

Had a request to make the featured image of all custom posts in a specific category redirect to external pages, each link being different, and the client needed to be able to change the URLs on demand. Not sure if the approach I took was the best, but it seemed to work!

The custom taxonomies were created in ACF. The idea was to make a meta box in the custom post that would save the inputted text to the database, which inturn could be called later.

add_action( 'admin_menu', 'url_create' );
add_action( 'save_post', 'url_save', 10, 2 );
function url_create() {
    add_meta_box( 'url', 'URL', 'url', 'TAXONOMY', 'normal', 'high' );
function url( $object, $box ) { ?>

    <label for="sub_title">Redirect to:</label>
    <br />
    <input type="text" name="url" id="sub_title" cols="60" rows="4" tabindex="30" style="width: 97%;" value="<?php echo wp_specialchars( get_post_meta( $object->ID, 'URL', true ), 1 ); ?>" />
    <input type="hidden" name="url_nonce" value="<?php echo wp_create_nonce( plugin_basename( __FILE__ ) ); ?>" />

<?php }
function url_save( $post_id, $post ) {
    if ( !wp_verify_nonce( $_POST['url_nonce'], plugin_basename( __FILE__ ) ) )
    return $post_id;
    if ( !current_user_can( 'edit_post', $post_id ) )
    return $post_id;
    $meta_value = get_post_meta( $post_id, 'URL', true );
    $new_meta_value = stripslashes( $_POST['url'] );
    if ( $new_meta_value && '' == $meta_value )
        add_post_meta( $post_id, 'URL', $new_meta_value, true );
    elseif ( $new_meta_value != $meta_value )
        update_post_meta( $post_id, 'URL', $new_meta_value );
    elseif ( '' == $new_meta_value && $meta_value )
        delete_post_meta( $post_id, 'URL', $meta_value );

Then redirect placed in the header to target just the specific post type and redirect to the previously saved URL

$queried_post_type = get_query_var('post_type');
if ( is_single() && 'issues' ==  $queried_post_type ) {
  wp_redirect( get_post_meta($post->ID, 'URL', true) );

Well it worked, which is great, but sure there was a better way!


Apple watch coming soon

I like new Apple stuff, and I like watches.

Early next year the new watch from Apple will be available, and I am certainly looking forward to it.

There seems a good amount of choices and comes in two face sizes — 1.5 and 1.65 inches, but I do worry that you will have to have a new iPhone at launch, though the iPhone 5 should be ok.

internets, web dev, WordPress

Update WordPress to Version 4.0

Hi all, new version of WordPress (version 4.0) is out. There is some blurb below. Please remember to back up your database, and any core files you have altered when you update your site. Here is a quick checklist for you:

Backup your database
Backup all your files at your hosting
(Square Apple provides hosting with daily automated backups so have a think about switching over!)
Verify the backups have been successful
(If doing the manual upgrade remember to also deactivate your plugins first).

Version 4.0 of WordPress, named “Benny” in honor of jazz clarinetist and bandleader Benny Goodman, is available for download or update in your WordPress dashboard. While 4.0 is just another number for us after 3.9 and before 4.1, we feel we’ve put a little extra polish into it. This release brings you a smoother writing and management experience we think you’ll enjoy.

Looks pretty good so far, stable and