Press "Enter" to skip to content

Category: Tutorials

How to Organize Headings for Accessibility

How to Organize Headings for Accessibility in your WordPress Theme

[series]Making your WordPress Theme Accessible Series:

  1. An Intro to Web Accessibility
  2. How to Organize Headings for Accessibility ( We’re here now )



In today’s post, I’m going to focus one aspect in making our WordPress theme accessible – and that aspect is headings. After reviewing what headings are, and what they’re for, we’ll go into our theme files and make any changes necessary related to headings. It should only take a few minutes and although we’re only focusing on headings in this post, it’ll bring us one step closer to making our theme accessible.

Let’s get started. As an FYI, I’ll be using TwentyThirteen for most of my references, but the theme I’m using on this blog is Hexa.

Leave a Comment

How to Create a Categories and Sub-categories Menu, Part 1

How Can I Create a Categories and Sub-categories Menu in WordPress?

I’ve seen this question asked a lot on the WP Forums and WP Stack Exchange along with several different answers. It really comes down to what you need. So, we’ll go over how to create a categories and sub-categories menu in two different ways and the pros/cons of each in this part of the tutorial.

First, before we get into this, did you know that a WordPress categories menu can be created without code and will also be editable on the dashboard? WpTavern tells you how!

Still interested in trying the PHP way? Awesome, let’s move on.

The two easiest ways to make this menu happen is to use either wp_list_categories or get_the_category_list. After we review them both, you can decide which option best suits your needs.

In Part 2 of this tutorial ( coming soon ), we’ll be going over how to write a categories and sub-categories menu from scratch using get_categories(). For now though, let’s get started with Part 1!


How to Add Counter Classes with a Global Variable

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:

  1. Some familiarity with loops and general PHP will help.
  2. 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
  3. 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:


Leave a Comment

How to Apply a Template to Sub-categories

The big question: Does category.php apply to the children of the targeted category?

The answer: No. So now what?

For those not familiar with the power of category.php within a theme, you can catch up here. In a nutshell, you can apply a custom template to a specific category just by naming the template file with a convention that gets automatically picked up by WordPress. It’s a really awesome feature to take advantage of, but there’s one problem.

Category.php will not apply to the category’s children/sub-categories.  So then, how do we apply a template to sub-categories? After lurking around online to find forum threads like this, and brainstorming with a co-worker of mine, I found some solutions to the problem and wanted to share them.

Before we begin:

  • You should have some knowledge as to how category.php works in a theme
  • You should have some basic understanding of PHP or at the very least, have taken a look at WordPress’ Conditional Tags
  • You should have access to your theme’s files for editing purposes
1 Comment