The default output for WordPress’ post_class template tag includes class names for just about every type of page view imaginable:
page-parent
search-results
logged-in
author
paged
Plus just about everything else except for category ID information. It gives some good category-specific class names, but nothing to represent the category ID. For example, including the post_class function like this in your markup:
<div <?php post_class(); ?>>
Will output something like this in your HTML source code:
<div class=”post-5 post hentry category-uncategorized tag-demo tag-site tag-test tag-themes tag-typography”>
So if you happen to know the actual names of the categories then it’s not really needed, but for theme development, it’s useful to be able to generalize category distinctions and have them available as class names. Why? Because then the theme designer can apply category-specific styles very easily, and without having to mess with using actual category names.
For example, if we had the first…
936 readersI recently shown you jow you can create a post or a comment programatically, which is very usefull when creating advanced WOrdPress themes or plugins. Today, let's have a look at another killer snippet: Add categories or tags to a posts, programatically.Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you
55 readersWordPress is primarily a blog platform. Not infrequently it is used as a CMS. But not just static pages play a role, but also posts, because they are giving more opportunities, having better performance and be published in feeds. Therefore, I prefer to use, in the context of WP as a CMS, posts more than
177 readersOne plugin which I use frequently on my WordPress development projects is the Top Level Categories plugin. What this plugin will do is remove the /category/ from the URL upon activation. For example: http://www.example.com/category/uncategorized/ will change to http://www.example.com/uncategorized/ No other configuration to the plugin is needed, all you need to do is activate. This
325 readersMany people have asked me how to show posts on their homepage only from a particular category or categories. So here is a simple and quick solution for doing this. Getting Posts from a Single Category Go and open your index.php file from your theme folder. Now search for this string :- <?php if (have_posts())
1761 readersTag clouds accomplish their varied font sizes by applying inline styling to each tag. The resulting font sizes can be really weird like style='font-size:29.3947354754px;'. There is nothing inherently wrong about that, but it feels a bit unsettling and less controllable. Mike Summers sent in a solution he uses on his own site. Let’s check it
2064 readersDo you sometimes get that feeling to go all overboard and do things differently with your design? OK, I might not be the most creative person with visual designs, actually I like simplicity, but the fact was that I recently switched to a single-column design for my own WordPress blog. With simplicity, and single-column design, came
196 readersWhen coding a WordPress site, you often need to get a category ID. If you ever wanted to be able to get a category ID from the category name, then just read this recipe, I'm pretty sure you will like it.Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can
1995 readersThe post_class() function in WordPress is pretty darn useful. It is used like this, in most templates, in a wrapping div of all the content you are outputting: <div <?php post_class() ?> id="post-<?php the_ID(); ?>"> <!-- Post stuff --> </div> I was in a circumstance where I wanted to add an additional class to what that
372 readersTemplate Tag body_class The coming WordPress 2.8 provides a new Template Tag, body_class. This function gives the body element different classes, which gives you the possibility to use it effectively with CSS. <body <?php body_class(); ?>> Like in the comment area and post classes, the WordPress-Developer get the best out of the database. Here an example if you
379 readersYou may want to display posts from a specific category on the homepage or other pages of your site. For example, you might want to have a box that displays the latest three posts from your News category, or have links to your latest podcasts. In a previous post, I gave the code that would display
4,108
Curious what others are searching for? Below are the most popular search terms over the last 30 days.

