In a previous SitePoint article, I provided an introduction to the WordPress Categories API thanks to the function wp_list_categories(). As we saw, this function is full of different options, and that’s why it’s a good idea to use it if we want to display a list of our categories.
However, it can’t cover all the possible cases, and that’s the reason why we find other functions in the Categories API. These functions allow us to retrieve raw data: in place of a HTML list of our categories, we can retrieve arrays containing these same categories.
The consequence is that it's simpler (and proper!) to display this data in a special way, whatever you can imagine as a DOM tree. We will begin here with functions that return objects containing all data relative to our categories. Then, we'll be interested in functions that only return specific information.
Retrieving Some Categories as Objects
Like links in the Links Manager, we can retrieve our categories as objects that contain all of their properties. We'll begin by describing these objects thanks to a function which only returns one category. Then, we'll use our newly acquired knowledge to play with all the categories we want!
Continue reading %Mastering the WordPress Categories API%
by Jérémy Heleine via SitePoint
No comments:
Post a Comment