Gasp! This is really cool, guys! How to add background videos to your WordPress Posts @ wpmudev.org. It involves a plugin for shortcode usage, and…
Rachel R. Vasquez, also known as Rachie with a Vee, is a WordPress enthusiast who loves writing, drawing, animation, and a million other things. She hopes to at least share her WordPress joy with others.
Ever wonder how to add counter/numbered classes to your posts? Is this the fourth post or the seventh? Well, if you have wished upon a star (or even if you didn’t, but it was more like cursing out your computer, that’s fine too), then your wish is about to come true with this tutorial.
In this tutorial’s example, we want our blog posts to have classes like “article-number”, and we can achieve this using the post_class(); function and a counter that we’ll set as a global variable.
It’s not as hard as you think. Also, keep in mind that this is a technique that can be applied to other scenarios too, and it’s not limited to just adding classes to our blog posts. Well, let’s get started, shall we?
Before we begin:
- Some familiarity with loops and general PHP will help.
- Might want to review what variables are. I also go over variables with better analogies in an old article of mine on the Pixafy Blog: Understanding WordPress’ $args Variable
- Make sure you have a theme that you can edit files in – for my example, I’m using TwentyThirteen. The files I’ll be working in are: functions.php, index.php, and content.php.
What we’re going to achieve:
The Required WordPress Theme Files
There are only 2 files that are actually required in a WordPress theme for it to be detected and applicable in WordPress. Those 2 files are style.css and index.php.
And then there are those “unsaid” files – those “secret” requirements that become the scuttlebutt amongst developers and are the difference between a good quality theme or “What noob built this thing?!”
So how far do you go? Aside from the required WordPress theme files, what files should actually be present in a theme regardless of whether they’re literally required and why? Well I’ve gone through a fair share of WordPress builds, and I’d like to share my thoughts on that.