Select Page

Recently, we ran into a problem where we needed the ability to exclude certain KingSumo giveaways that were running, from showing up on a primary giveaway rotator we had created. This sounds like a simple enough job – our initial thought, we can just exclude ‘X’ category from the slider. Until we found that by default KingSumo does not support categories or tags.

The last thing we wanted to do was have to modify the giveaway plugin itself, as that would have required it to be re-patch it every update. We also did not want to have to create a manual array with the postID’s we wanted to exclude. So, we set out to find a way to use the least modifications necessary in order to get the exclusion up and running as well as make it as user friendly.

Our first task was to add see how we could add the categories field to the KingSumo system setup … it’s a custom post type. However, we wanted to not modify any of the actual plugin since we didn’t want to have to come back with each update and make the same change. The solution, hook the existing custom post type with our own.

We then added the category taxonomy, but found that once a category was added there was no way to remove it (or even see it in some places). This was due to the post terms not being saved when they (the categories) were getting added or removed from the individual giveaway and our goal was simplicity and steps that would be easy for anyone to replicate across any site. We kept the hook (since we had a couple other uses for it) but removed the category taxonomy.

Enter the Advanced Custom Fields plugin by Elliot Condon, this plugin would allow not only us but future site developers (at any skill level) to make quick and easy changes to the custom post type, all without coding. Best of all saving the terms to the post where was as simple and easy as checking a single box.

First we created a new Field Group within the ACF plugin options. Inside this newly created Field Group we started inserting options that would be used with the editor of the giveaway itself. (* Make sure to select “Load & Save Terms to Post – to save the options you select to post).

KingSumo-Setup-the-Field-Order

Just below we set the rules for where these new options would show up. We setup the categories options (above) to show if the post type was equal to our giveaway post type.

KingSumo-Category-Location

This is how the newly created options appear within the individual giveaway.

KingSumo - Category in Giveaway

We then had to find the category ID of the category we had just created – this could be found under Posts -> and Categories. If you hover over the category the category name on the bottom of the screen you’ll see category&tag_ID=XXXXXX , you will need the tag_ID number, this is what we will add to our slider loop to exclude.

The last thing we had to do was pass the category exclusion to the rotator in our list of arguments. This was done by adding  ‘category__not_in’ => (Insert tag_ID number)

We then checked out the rotator, tested the exclusion by adding / removing giveaways to the rotator and didn’t have a single issue.