Simon Griffiths Blog

My thoughts on …. everything

Adding a Default Category to a WordPress Custom Post

without comments

I have been searching for a way to add a default category into a WordPress Custom Post and finally got to a method that seemed to work for me. The explanation I came across was a bit vague so I thought I would try and clear it up here: –

The Code

// Adds the category to the jobs post automatically

function add_jobs_category_automatically($post_ID) {
global $wpdb;
$cat = array(139);
wp_set_object_terms($post_ID, $cat, ‘category’);
add_action(‘publish_job’, ‘add_jobs_category_automatically’);


line 1: function add_jobs_category_automatically($post_ID) {

This just sets the name of the function, in this case “add_jobs_category_automatically” declares it as a function and says what it applies to.

CHANGE ‘add_jobs_category_automatically’ to anything that will make sense to you.


line 2: global $wpdb;

Ok, I’m guessing at some of these, but I would say that this means that the function applies globally to the wordpress database

CHANGE: Nothing


line 3: if(!has_term(”,’category’,$post_ID)){

Some WordPress gubbins!

CHANGE: Nothing


line 4: $cat = array(139);

This is the category number you want to apply to the custom post. In my case it was 139, but yours could be anything.

To find the category number in your WordPress admin interface, go to Posts, Categories and mouse over the category you want to add automatically. You should see a number under category&tag_ID=139, the number is what you need (if you can’t see it by mousing over copy the link and paste it somewhere, it should look something like Just copy the number and paste it into this line.

CHANGE: The number to your category


line 5: wp_set_object_terms($post_ID, $cat, ‘category’);

Some WordPress gubbins

CHANGE: Nothing


line 6, 7 just closing brackets
CHANGE: Nothing


line 8: add_action(‘publish_job’, ‘add_jobs_category_automatically’);

This is the tricks one, so I will break it into 3 parts

add_action – Some WordPress Gubbins – CHANGE: Nothing

publish_job – This says what your custom post type is called that this should apply to. In my case it is the job in publish_job. You will need to change the job to your custom post type.

To find this go to your custom posts, to the page where they are listed. The URL of the page is key. In my site it is You need what comes after the post_type= in this url. As you can see mine is job.
CHANGE: publish_job, the job to your custom post type.

add_jobs_category_automatically – This is the function you created in line 1, so you should change this to the function name you made there. In my case line 1 was “function add_jobs_category_automatically($post_ID) {“, so you can see that the bit you need is between “function” and “($post_ID)”
CHANGE: All of it to your function name in line 1


You need to add your final code into the functions.php file, somewhere before the closing ?> tag. In mine I added it just after the function to create the custom post. So that whole section looks as follows: –

// Add Careers Custom Post Type

add_action( ‘init’, ‘register_cpt_job’ );
function register_cpt_job() {
$labels = array(
‘name’ => _x( ‘Careers’, ‘job’ ),
‘singular_name’ => _x( ‘Job’, ‘job’ ),
‘add_new’ => _x( ‘Add New’, ‘job’ ),
‘add_new_item’ => _x( ‘Add New Job’, ‘job’ ),
‘edit_item’ => _x( ‘Edit Job’, ‘job’ ),
‘new_item’ => _x( ‘New Job’, ‘job’ ),
‘view_item’ => _x( ‘View Job’, ‘job’ ),
‘search_items’ => _x( ‘Search Careers’, ‘job’ ),
‘not_found’ => _x( ‘No careers found’, ‘job’ ),
‘not_found_in_trash’ => _x( ‘No careers found in Trash’, ‘job’ ),
‘parent_item_colon’ => _x( ‘Parent Job:’, ‘job’ ),
‘menu_name’ => _x( ‘Careers’, ‘job’ ),
$args = array(
‘labels’ => $labels,
‘hierarchical’ => false,
‘description’ => ‘Careers section for displaying jobs on the site.’,
‘supports’ => array( ‘title’, ‘editor’, ‘excerpt’, ‘author’, ‘thumbnail’, ‘custom-fields’, ‘revisions’, ‘page-attributes’ ),
‘taxonomies’ => array( ‘category’, ‘post_tag’ ),
‘public’ => true,
‘show_ui’ => true,
‘show_in_menu’ => true,
‘show_in_nav_menus’ => true,
‘publicly_queryable’ => true,
‘exclude_from_search’ => false,
‘has_archive’ => true,
‘query_var’ => true,
‘can_export’ => true,
‘rewrite’ => true,
‘capability_type’ => ‘post’
register_post_type( ‘job’, $args );

// Adds the category to the jobs post automatically

function add_jobs_category_automatically($post_ID) {
global $wpdb;
$cat = array(139);
wp_set_object_terms($post_ID, $cat, ‘category’);
add_action(‘publish_job’, ‘add_jobs_category_automatically’);

The green text at the top is my custom post type and the blue test at the bottom is the code to set my default category in the custom post.

Written by Simon

March 23rd, 2015 at 10:44 pm

Posted in Uncategorized

Aldi Mobile – Review

without comments

I have been a big supporter of Aldi Mobile and have recommended it to many people. The service is Telstra 3G, so as long as you haven’t got a need for 4G support it seems to offer great value for money.

However, recent changes to Aldi plans and terms of services have shown another side to their business, which I for one do not like a bit.

Aldi Mobile Plans

Previously Aldi had an Unlimited plan which for $35 per month offered you unlimited call, texts and 5GB of data. This was great value, but in a recent change, they have slashed this to 2500 minutes of calls, 2000 SMS and 2.5GB of data.

To sweeten the deal, there was obviously a price reduction involved…actually not! They halved the data and restricted the call time but kept the price exactly the same.

On top of this, they have introduced a ‘fair use’ policy that, well… it’s hard to define it as being fair in any shape or form. This amongst other things adds that: –

  • You can’t make more than 300 mins of calls, 300 SMS or download more than 400MB of data per day for 3 consecutive days
  • You can’t make more than 480 mins of calls, 500 SMS or download more than 1000MB of data on any given day

These apply to any mobile plan or addons.


Now forgive me if I’m wrong, but if I buy a 2GB data pack for the month I expect to be able to use it as and when I like. Typically I use on average 50-80MB per day when not on wifi, so I then let my son use it to watch youtube videos while I was out at dinner. Guess what, that is apparently not fair use!

I should add that I got no warning that the usage was too high, until I got a email threatening to cut me off 24 hours later.

I should note again that I have paid for the data, and lets face it. If they have a number of customers, it shouldn’t matter to them if I use it on any one day or another as the affect would be spread out amongst their customers.


Aldi’s plans are still a great deal if you … don’t use your phone much and do that consistently. The previous unlimited plan is no longer the value it once was and data restrictions mean that the data packages have become next to useless too.

Probably my biggest complaint is the way Aldi’s have done this. They slashed the value of a previously good plan while maintaining the price and enforced new ‘fair usage’ policy that is anything but fair.

It is true that Telstra and others have similar policies on fair usage, but these tend to be far less restrictive, certainly on the data side where a monthly limit is what you tend to get. It’s almost funny that at the same time as pushing services like Foxtel Go, services such as Aldi’s don’t seem to understand that minutes of video streaming is a huge amount of data.

My advice, after being a huge advocate for them is to probably steer clear. Most of us with a smart phone will have times when we use data heavily and having Aldi come down and say a day after the event: –

If this is the second time you have breached section 5.3 of our Acceptable Use Policy, then your service will be suspended. We will attempt to contact you before we suspend your service to let you know when it is going to happen. This suspension will block both your incoming and outgoing calls, but you will still be able to make calls to 000 emergency services and the ALDImobile service centre on 2534. You will need to find a new provider and transfer your number to them.

Thankfully this was first time being caught by this but it is certainly not my idea of a great service!

Written by Simon

November 18th, 2013 at 1:31 pm

Posted in Tech Comment

Tagged with , , , ,

Slidedeck: How to Add Individual Slidedecks to page headers

without comments

If you are like me, you love Slidedeck ( for the ease of use for me and my clients when I have handed over the site.

Typically I use Slidedeck for what is known as a hero slides how on the home page and very occasionally on the page itself and Slidedecks combination of methods of site integration makes this really easy.

However, what if you have a site that needs to have product slideshows in the header area? Again, it’s easy if you can have a layout for each page, but the problem comes in where you need a single say ‘products’ layout to cover a large range of products/pages. There is just no way to change the slideshows on a per page basis, if the slideshows is to be in the header.

The solution is actually much easier than you would probably think. Using a combination of Slidedeck with another plugin (Advanced Custom Fields), and a small piece of php code inserted into your theme. Using this method you should be able to:-

  • Provide a visual way to enter a Slidedeck code into an individual page
  • Allow product (or similar) pages to show slideshows in the header rather than on the page. Even if they use the same theme template

This will take the form of step by step instructions. It’s worth noting that I am no php coder, so any additional help with the code beyond what I did to ‘make it work’ would be appreciated.

  1. In your copy of WordPress, install Slidedeck and create a slideshow as an example we can use.
  2. Install the plugin “Advanced Custom Fields”. This is what will allow you to create both the visual interface and the field of information the post needs to know which slideshow it needs to display
  3. Once you have advanced custom field installed, you will see Custom Fields at the bottom of the left side menu bar in WordPress.
  4. I created a custom field called Page Sliders, and gave it the settings as follows: –
    Advanced Custom Field Setip
    Advanced Custom Fields Setup
    You can see from the above that I have a home page template where I don’t want to show this as an option, as it will use a standard template and slideshow with a slightly different layout. Selecting “Standard Metabox” ensures that there will be a box for the WordPress page editor.
    My description is probably a bit over wordy btw, but I have done this assuming it won’t be changed for a while and the user will more than likely have forgotten what to do when they need to make changes.
  5. All the above should give you is something like the below. This gives you an area in your page to add the Slidedeck shortcode, so that it will be stored with the page. At the moment, that is all that this does as we have not yet integrated the code we need into the theme.
    ACF in WordPress interface
  6. Now here comes the hard bit unfortunately! We need to edit our theme. It’s actually easier than it sounds, but I would advise you to back up the theme code before you start to edit it. You can either FTP the theme to your local machine, or even copy all the code and paste it in a text file. You do all this in <Appearance><Editor> from the WordPress sidebar.
  7. Typically when you open the editor you will see your themes CSS file. If you have set up various page templates, you will also see those listed, otherwise you will just see the one template, the header template, footer template etc.
    Which one of these you want to edit depend on your theme. I would start by looking at the header, where you will probably see, the head section of the document, then the header of the site, then the navigation, then the top of the main content area. In my case I want the slideshow under the navigation and in the main content area, so instead of the header.php I can put the code in the page template.
  8. Opening up the page template, you will see some code to get the get the header <?php get_header(); ?>, so the code is to go under that in my case (just above the main content). The code you need is: –
    <link rel=’stylesheet’ id=’slidedeck-css’ href=’′ type=’text/css’ media=’screen’ />
    <div id=”slider-custom” style=”position:relative;left:-20px;top:-24px;”>
    $sliderdeck = get_field(‘slidedeck_shortcode’);
    <?php echo do_shortcode($sliderdeck); ?>
    </div> <!– slider-custom –>This links to the slidedeck css files (in my case I used the half moon slidedeck style, so linked to that), creates a new div (the styles included were required for my theme, but you may need to change the numbers), then get the slidedeck shortcode from the custom field in the page, then add it into template.
  9. Hopefully that should now all be done. The only thing left to do is set up the page.
  10. You can go and get a shortcode directly from slidedecks interface, but for me the easiest way is to copy the code in the explanation, then change the number according to the slidedeck you want.
    The above shows the interface on the post page and the below in slidedeck. Note that you have to mouse over the deck you want to get the ID number.
  11. Your end result should look something like “[SlideDeck2 id=2641]”. When you preview the page, you should now see your custom slidedeck up in the head of your page.

Hopefully, this will help anyone who has been battling with this problem as I have. If you have any comments, please leave them below. PHP code suggestions would be particularly helpful!

Written by Simon

October 13th, 2013 at 2:56 pm

Fixing a MacBook Pro with Liquid on the Keyboard

without comments


I had the misfortune the other day of spilling Ribena on the keyboard of my MacBook Pro. A short while later I got the sad Mac icon and it refused to boot up properly. I thought I would write down what I did to get to the stage where I am now typing out this article on the previously broken computer.

The first step is to take the system into Apple. In my case despite trying to be as nice as possible, the sales ‘genius’ was that busy writing it off on their system that he almost forgot I was now without a computer. Basically he said (without ever looking inside it) that they would need to replace everything and the cost of doing that was slightly more than a new MacBook Pro. I did manage to get him to run a software check and that basically told me that the hard drive was not doing so well.

So knowing that the computer is said to be a write off, I thought that I might as well try and revive it myself, but I needed to buy a few things to do some testing.

First thing was to test that the computer was still functional. I was lucky here as I create a mirror back up on an external hard drive every week. If you don’t though, create a recovery disc and try and boot into that. In my case from the external drive everything booted and ran ok.

The next thing I bought was a USB to SATA connection device. In the Australia you can get these from jaycar ( or buy from OWC Macsales ( These devices allow you to take your hard drive out and try to connect to it.

It’s pretty easy to open up your MacBook. Follow the instructions on the Macsales website ( to take off the back and remove your hard drive. You might be using these later too.

Once you have the drive out, plug it into your USB device and try to connect to it from another machine. I couldn’t on my system.

Next step is to buy another hard drive. I would do this from OWC again and in my case I picked a similar drive to the existing one which was 750GB at 5400rpm. You could go to any drive you want so SSD for the ultimate in speed or for a bit of a boost a 7200rpm drive. I didn’t go with higher speed as I am a bit worried about heat of a faster spinning drive in a notebook in Brisbane, Australia, but now I regret not going for an SSD which is probably the ideal combination of speed and fast access.

When my drive came a few days later I mirrored the hard drive copy I had, from a back up via Carbon copy cloner or super dooper onto the new drive then installed that into the MacBook. If you are lucky here that’s as far as you need to go. In my case though that still didn’t work.

What I found was that I still couldn’t boot onto the new drive, but if I booted onto a USB drive, I could see it.

The next step was then a reformat of the drive again and cloning the drive from the USB.

With the newly re-cloned drive, I could not only see files, but it will boot quite happily.

The end result is a MacBook Pro that was written off by Apple, is now perfectly good and will probably last me for another couple of years. The only compromise is the lack of a DVD drive. As I rarely use this and I have the old drive as an external drive using the OWC DVD drive enclosures, this doesn’t seem to be too much of a problem.

Written by Simon

October 13th, 2013 at 11:47 am

Posted in Tech Comment

Tagged with , ,

Bauhn / Aldi Hard Drive Docking Station Review

with 8 comments

I bought one of these a few months ago, but they seem to repeatedly come up when Aldi’s are doing a tech special week.

The only thing I can say is DO NOT BUY!

They have a fundamental problem in that they don’t fit any hard drives! I have tried 6 different drives from 2.5″ laptop drives to 3.5″ full desktop drives and none of them fit!

The problem seems to be that the plastic casing gets in the way of the the drive mounting into the sockets. This doesn’t seem to be a tolerance error on this particular unit either as the case is locked into a base. I haven’t taken this all apart yet (as that looks like a nightmare of a job), but I really should not need to do that, and neither should you. Just don’t be fooled into buying it!

I also tried the After Sales Support telephone number on the bottom of the unit and that is unobtainable!

btw. This one is a Bauhn Product Number 1 photo 2


Written by Simon

April 17th, 2013 at 9:31 am

Sociable Widget in WordPress

without comments

I use the Sociable plugin on a couple of the blogs I look after and was surprised to see that there is no sidebar widget. That means that if you want to add social icons to your home page and that features a few different posts, essentially you can’t.

After looking at this a few different ways I managed to pick out the code from the plugin and adapt it to be used in a text Widget. The code is as follows with the things to change shown in blue: –


<div class=’sociable’ style=’float:none’>
<ul class=’clearfix’>
<li id=”Facebook_Counter”>
<iframe src=”
&action=like&colorscheme=light&font” scrolling=”no” frameborder=”0″ style=”border:none; overflow:hidden;height:32px;width:100px” allowTransparency=”true”></iframe>
<li id=”Twitter_Counter”>
<a href=”” data-text=”Your Site/Page –” data-url=”” class=”twitter-share-button” data-count=”horizontal”>Tweet</a><script type=”text/javascript” src=”//”></script></li>
<li id=”LinkedIn_Counter”><script src=”” type=”text/javascript”></script><script type=”IN/Share” data-url=”” data-counter=”right”></script></li>
<li id=”Google_p”><g:plusone annotation=”bubble” href=”” size=”medium”></g:plusone></li>
</div><!– End Sociable –>


The green highlight was because the row of icons can’t display across the sidebar so tends to go all over. You can modify this by closing one unordered list (ul) and opening another.If you include a lot of icons just repeat this.

I should add at this point that this is for the big 4! Facebook, Google, LinkedIn and Google+. If you include more you will need to view the code of a page with the Social plugin on it, search for sociable then copy the code and change the page details.

Once you have your code sorted out, just go to your WordPress Widgets area, add a text widget and paste your code in. With any luck it should all flow in and include the correct number of likes etc for the page.

Written by Simon

October 1st, 2012 at 5:57 pm

Posted in Web development

Tagged with , ,

Jackson USB power/charger – iPad beeping

without comments

I recently bought a Jackson USB power /charger and have just been charging my son’s and his friends ipad in the USBs.

The iPads started beeping about every second after half an hour or so. After a lot of restarting etc I checked the supply and sure enough the blue light on it was flashing on and off in the same rhythm. I unplugged the iPads and the beeping stopped, so it looks like the supply was switching on and off. When I went to unplug the unit from the wall it was very hot!

My guess is that the two iPads were causing the charger to overload despite the 10A rating. Thankfully the unit was protecting itself by switching on and off but who knows what would have happened if I had been out and just left them plugged in!

Not sure whether this is a fault with mine or a general problem but please take care. It’s worth noting that I have had iPad and iPhone plugged in previously with no problems.


Jackson USB power / charger


I have had a response from the manufacturer as follows: –

Two iPad devices would draw well over the rated current of this charger (1 Amp), which would cause the overcurrent protection on the charger to activate. The overcurrent protection is calibrated to activate well before a hazard could exist, and this is all tested as a part of our QA procedures, so we can confidently state that at no time would there have been any risk to you. Even with this protection in place, we do recommend that you do not attempt to exceed the rating, as such we would suggest only connecting 1 iPad at a time to the device.

I think their last line summarises this nicely.

Written by Simon

September 1st, 2012 at 9:01 pm

Is Google Sidelining Analytics?

without comments

With new tracking rules coming in from both Europe and I’m sure the rest of the world and modern browsers including a “do not track” feature it must be hard for Google to see a future for Analytics. Increasingly it seems that it is trying to depreciate the value of analytics by reducing the value of the information we collect, in favour of the information it collects.

Let me give you an example: –

  • Recent changes to Analytics have logged in users not passing their keyword information through to Analytics (although this isn’t evident in Adwords).
  • Google is encouraging people to stay logged in by increasingly pushing us to be logged in to use their services.

The end result of these two policies is of coarse that Analytics is seeing less and less keyword information, but Google is seeing more and more from it’s logged in users.

If I was to be cynical about this, I would say that it is an attempt by Google to still collect all the information it wants (as I’m guessing its in their terms of service), but not passing that information through as it has done before.

So what can we do about it? More and more it seems that Google is leaving itself open for new competition. In the analytics field there are paid options which are now starting to look quite attractive now we are hooked on the value of this type of information. If any of you out there have used any, please let me know. I’d be interested on your feedback.

Written by Simon

June 6th, 2012 at 12:02 am

Posted in Uncategorized

WordPress on Crazydomains

with 16 comments

Installing WordPress on Crazydomains hosting drives me nuts!!!

I always forget how to install it, as to say that it’s not the most obvious installation method is probably the understatement of the century! For anyone struggling (and for me the next time I do this) this may help: –

  1. Fantastico installation from Crazydomains hosting DOES NOT WORK. I have tried this on different accounts using different methods and it never works. Don’t even bother wasting your time trying.
  2. Download WordPress and follow the instructions on
  3. When you come to configuring the wp-config.php file you will need to add in the database, user, password and hostname. This bit always completely throws me as these are not what you expect at all ie they are not what you set up in phpMyAdmin! The following is what you need: –
    1. DB_NAME – Here you need to include your account (not database username). If you are using phpMyAdmin you will see this on the left hand of the interface, but you need to include the first and second level bullet which shows ‘account-name’ and ‘database name’. Eg if your account name in Crazydomains is ‘account-name’ and the database you set up is ‘wordpress’, you will need to use ‘account-name_wordpress’.
    2. DB_USER – Follows the same format. You will need to include your account name despite the fact this is not shown anywhere. You will also see in phpMyAdmin a username like username@localhost. You need the first part of this before the @ sign. You need to then include the Crazy domain account name too. Add in ‘account-name_username’.
    3. DB_PASSWORD – Just the password. Finally something simple.
    4. DB_HOST – Just ‘localhost’.

Hopefully this will get you set up. After that just run the install script and you should connect ok!

Good luck!

Written by Simon

June 2nd, 2012 at 5:14 pm

Spry Collapsible Panels to jQuery

without comments

Moving Spry Collapsible Panels over to jQuery is actually a lot easier than I thought it would be.

Just to give you a bit of background, Spry is a javascript library that comes with Dreamweaver. They really pushed it to start with, but haven’t updated it since 2006, so to say that it’s a bit long in the tooth is an understatement in web terms. JQuery on the other hand is the javascript library of choice and in the latest version of Dreamweaver, also seems to be pushed over Spry.

However if you have already included Spry on your page, you may just want to keep the existing html markup exactly the same and swap over to a jQuery system. I did this with an admitted simple single panel system (used for dropping down a form), as below: –

1. Add jQuery into your page. I’ve used an old version and am pulling this off Google servers as follows

<script src=”” type=”text/javascript”></script>

2. Remove Spry javascript code from your page.

3.Create a new javascript file and add the following code

$(document).ready(function() {
$(‘.CollapsiblePanelTab’).click(function() {
if ($(‘.CollapsiblePanelContent’).is(‘:visible’)) {
} else {

4. Link to this new file in your document (and below where you add in the jQuery file).

Written by Simon

October 27th, 2011 at 1:01 am