Get the Category ID by the Category Name

Here’s a handy function that takes the category name and returns the category id: function get_category_id($name) {     $term = get_term_by(‘name’, $name, ‘category’);     return $term->term_id; } Save this function to functions.php and call it like any other function. In this example we use it to return a list of all posts in a category […]

Finding the current theme directory in WordPress

WordPress is, for the most part, pretty intuitive. However, one place where WordPress complicates things unnecessarily is in finding the current theme directory. That’s not to say there aren’t intuitive ways of obtaining this information already built into WordPress: Need the current theme URL? Use get_template_directory_uri(). Need the absolute path to the current theme directory? […]

Redirecting to a subdomain

It’s a familiar scenario. The client is looking to establish a web presence as quickly as possible, usually in the form of a blog, usually WordPress, which is usually installed in its own directory which is usually named “blog”. While the main site is coming together we want people to see the blog when they […]