WordPress Categories to the Body Class CSS Plugin

I needed to make CSS changes to a specific category on one of my WordPress sites, this plugin is the result. My WordPress side project started off as a simple review blog and then evolved into more than it was supposed to be. Because of this, I ended up with categories where I should have had custom post types. Rather than making the custom post types and converting the posts over I used this quick fix to make a certain category display much differently than the rest.

Download Plugin

To be fair and give credit where credit is due – the code came directly from this blog post by Philip Newcomer and I put it into a plugin rather than adding it to my theme’s functions.php file.

Here is Philip’s description of the code:

Here’s a little function that will add each of a post’s categories to the body class of the single post page (assuming your theme uses the body_class template tag)..

To see how to make plugins instead of editing your theme’s functions.php file check out this blog post by Brian Hogg.


Enable Lightbox and Extra Media Functionality to WooCommerce 3.0 Themes

I upgraded a WooCommerce site using the theme Wp Portfolio and all my products started opening images in new tabs rather than a lightbox.

First I made sure my theme was updated, but it made no difference. So, naturally I started searching Google for answers. It turns out that WooCommerce 3.0 added new/different media functionality which removed the old lightbox and most WooCommerce geared themes haven’t been updated to use the new functionality.

In order to enable the new media functionality on my WP Portfolio theme I edited the functions.php file by finding the add_action(‘after_setup_theme’, ‘wp_portfolio_setup’); line and add the following three lines below it. (Your line will have wp_portfolio replaced with your themes slug instead.)

and the functions.php will look like this:

giving your WooCommerce store functionality like this:

Enjoy your newly working Zoom features and fixed Lightbox functionality! Don’t forget to bug your theme developer to update their theme release with the new WooCommerce 3.0+ media functionality!

Default Windows IIS WordPress web.config XML

Recently I was migrating a test site from a Linux/cPanel based web-host over to a Windows Server running IIS. After migration, none of the site’s pages or posts worked and all returned 404 errors.

I’m familiar with .htaccess files causing 404 problems so I knew that was probably the issue, and since this was now on a Windows server I knew it had to be the IIS equivelant file “web.config” causing problems. Upon further investigation I realized there was no web.config file at all even though I was used to it always being there after setting WordPress up through IIS. Since I’m using Server 2016 for the first time, perhaps things are different and web.config files aren’t created automatically any longer.

Either way, my problem was solved by adding this XML to a newly created web.config file in the site’s root folder:

Now pages and posts are working properly and pretty permalinks are functioning as they should! Note: If “URL Rewrite” is not installed then it will need to be first in order for this to work.

iPage 10MB phpMyAdmin Upload Limit 1

Get Around IPage’s 75000 Query Limit and 10MB phpMyAdmin Upload Restriction Using BigDump

If you’re like me, you started your website endeavors on a budget web-host just to get the hang of things before moving on to bigger and better things!

If you’re unlucky, like me, your starter web-host happened to be iPage, or some other crap web-host, with insane limitations and restrictions on all sorts of PHP and SQL/MySQL operations that aren’t listed openly on their website.

If you’re very unlucky, you’re still on your crappy web-host and are trying to restore a .sql backup via phpMyAdmin while being overly limited on the size of the backup you can upload. Well guess what.. chances are if they’re overly limiting your .sql upload size, they are limiting you on other important things as well!

Bummer, huh?

iPage 10MB phpMyAdmin Upload Limit 1
iPage 10MB phpMyAdmin Upload Limit 1

You’re probably seeing an upload limit like the one pictured above. So, like any smart person, you’ve looked into splitting your backup into multiple files to restore, but the SQL Dump File Splitter is either not working for your backup or you don’t even want to try it out of fear of messing something up.

BigDump Saves the Day by Automatically by Splitting your Database Import into Multiple Staggered Imports!

iPage 10MB phpMyAdmin Upload Limit 2
iPage 10MB phpMyAdmin Upload Limit 2

Now that you’ve found out about BigDump, you are 100% certain the day has been saved, right? Given how crappy your web-host is, prepare to have you dreams dashed!

iPage 10MB phpMyAdmin Upload Limit 3
iPage 10MB phpMyAdmin Upload Limit 3

You didn’t think your sub-par web-host was going to let you off the hook that easy did you? Ha, Never! The above image shows that the importing database user has exceeded an hourly max amount of queries.. What Now?

You could split your backup into multiple files and wait an hour between each import. Your web-host will surely tell you that they can lift/raise the limits placed on your PHP, or make the import for you, at a cost of course.

There is an Easy Way to get around the Low phpMyAdmin Upload Limit, and your Web-Hosts CRAZY low ‘max_questions’ limit!

Just make a few different users to your database, and each time you hit the max_questions limit using BigDump, just edit the BigDump.php script to use a fresh database user and then REFRESH the page where you hit the ‘max_questions’ error and the import should restart where it left off using the new database user added to BigDump.php! Repeat as needed until your import is complete. 😉

I’ve used the above method countless times on my old web-host and would have been screwed without it! I’ve contacted the creator of BigDump and asked him if he could add an optional feature to the script that will allow multiple database users to be used – hopefully he obliges. (Update: Since I’m the only person to ever ask him about adding a user-rotation to the script he has not done it, and probably will not unless more people request it!)

Let me know if you have any questions or if this post has helped you by leaving a comment below!

WordPress SEO - Titles & Meta - Types 1 - JSnowCreations

Fix Yoast’s WordPress SEO Title & Meta Variables with Types Custom Fields

If you are like me you insist on using Yoast’s WordPress SEO plugin to control you WordPress website or blog’s page titles and meta tag data via the “Titles & Meta” settings page found in the WordPress SEO. If you’re really like me then you are also too lazy to custom PHP code your WordPress theme to have custom post types, custom taxonomies, and/or custom fields so you instead use a plugin to quickly and easily make all the custom post types/taxonomies/fields for you, such as the “Types” WordPress plugin!

Yoast’s WordPress SEO plugin is a breeze to use even for beginners, and the Types plugin is also fairly easy to use for moderately experienced WordPress users. However, getting custom post types, custom taxonomies, and custom fields to work with the “Titles & Meta” variables within WordPress SEO’s settings can be tricky.

Allow me to clear up the minor issue I ran into with WordPress SEO’s Titles & Meta variables and Types custom fields.

If you look here or one of the many other WordPress SEO guides you will find many options to use on the Titles & Meta variables, but the three we are focusing on in this post are:

These three variables are used to input values from custom fields, taxonomies, and taxonomy descriptions into WordPress SEO Titles & Meta fields which then control SEO Meta Tags.

Custom taxonomies and taxonomy descriptions work just as you would think – replace “custom-tax-name” AND the surrounding “<” “>” brackets in the %%ct_…%% and %%ct_desc_…%% variables with your custom taxonomy slug.

Examples:

After using these variables correctly, your WordPress SEO Titles & Meta fields should correctly input custom taxonomy names and taxonomy descriptions into your site’s SEO meta tags!

However, the custom fields variable has a small issue with the Types plugin that might cause trouble for some.. It’s not even really an “issue”, just something many will overlook. Make sure to read below before you go searching “%%cf_%% not working with Types custom field” at Google!

The problem with WordPress SEO’s Titles & Meta variables and Types custom fields, and how to fix it!

WordPress SEO - Titles & Meta 1 - JSnowCreations
WordPress SEO – Titles & Meta 1 – JSnowCreations

Given how simple it is to get custom taxonomies and taxonomy descriptions made with the Types plugin working with Yoasts’s WordPress SEO Titles & Meta, you’d think getting custom fields from Types to work would be as simple as plugging the custom field’s slug into the %%cf_…%% variable such as %%cf_download-developer%%, right?

Wrong! The Types plugin, along with many other custom-field-creating plugins, adds a prefix to the beginning of custom field slugs and Types’ custom field slug happens to be “wpcf-“. So, in order to get custom fields created with the Types plugin to work with WordPress SEO’s Titles & Meta variables you must simply add the wpcf- prefix from Types to your Titles & Meta variables.

Examples:

After adding the extra prefix from Types to your custom field slugs entered in the Titles & Meta variables in WordPress SEO’s settings, your SEO meta tags should start correctly outputting custom field values! 😀

WordPress SEO - Titles & Meta - Types 1 - JSnowCreations
WordPress SEO – Titles & Meta – Types 1 – JSnowCreations

Yoast’s WordPress SEO’s Titles & Meta variables work great with custom fields made with the Types Plugin once you know what your doing!

I suppose it also helps if you find my post regarding the issue rather than blindly trying and getting things 99% correct like the guy here who just left in the “<" ">” brackets from WordPress SEO’s guide on Titles & Meta variables. Too bad the PAID support he got didn’t give him the easy, and correct, solution of just removing the brackets! 😮

Please, comment below with any questions of comments you may have about this post, or anything else regarding Yoast’s WordPress SEO plugin or Types!