Support » Fixing WordPress » Post Type, Cateogry, Taxonomies, and Fields– Which to Use for What Information?

  • I am working on a site with articles and information. I also set up a separate post type that includes listings for restaurants and stores (about 40 in total that won’t change frequently).

    I think what I need to do is add “restaurants” and “stores” as post types (using Custom Post Types UI) since they have slightly different formats.

    I created these post types and have added some custom taxonomies (neighborhood, price) but these don’t appear on the public site.

    I also originally thought that some of the information like addresses, hours, etc. would work best as custom fields. After working with custom fields, I found that it’s not exactly appropriate for this situation, but I find myself going back to it. WP just isn’t the best system for business directories but I decided to use it anyway because the blogging and commenting component is the most important part of this site.

    So: Do you think things like listings of restaurants and stores are best presented as categories or custom post types?

    How can I display custom taxonomies?

    Do you think addresses and hours are best presented as custom fields? Have you seen any examples around of custom fields being used this way?

    Thanks in advance!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi bwesty!

    I think overall you’re on the right track in setting all this up. With items which are very obviously segregated (for example, posts, restaurants, books, movies, etc) I would suggest post types.

    If you want to build directories like this, WordPress is great, but it can be best utilized if you have some PHP knowledge. It is possible to add a meta box to a post type, instead of using the custom fields. Database-wise, the end result is usually the same, but it makes for a very easy management system.

    I manage a popular scientific blog where we have online seminars, which are a separate post type. To associate a speaker with a seminar we use a custom box, which is basically a list of users who are speakers. We could have just used a custom field labeled “seminar_speaker”, and then enter the ID of the user, but this is obviously much less intuitive.

    One thing I don’t understand is why you use taxonomies for price? Are the values limited (eg: low price, mid-price, high priced)? If so, taxonomies are fine, if you’re using values all over the place (like $3, $6, $18, etc), I recommend you use custom fields / custom meta boxes.

    So I think that your setup of custom posts / taxonomies is fine. If you would like to take a look at how to add a custom meta box, take a look at the codex here, or you could try this tutorial. I didn’t read it completely, so please excuse me if it is not exactly the right one.

    To show custom taxonomies, you can very easily use wp_list_categories(). Take a look at its description in the Codex here.

    If you custom taxonomy has the name ‘restaurant_prices’ you could use
    wp_list_categories('taxonomy=restaurant_prices') to show a list. To show a taxonomy next to a post, you will need to use get_object_terms(), you can take a look at the description of it in the Codex. This returns an array of objects, so it won’t display directly. You will have to cycle through each assigned taxonomy and display them using PHP.

    I hope I could help, good luck!

    Daniel, THANK YOU. This is fantastic information.

    Re: taxonomies, I don’t think this is the correct solution. The only places I could really use them is with neighborhoods (this is one city, so there are a set number of neighborhoods), and prices (scale of 1 to 5, just shows how expensive the restaurant is). Those are the only uses I could find, and I want this information to be integrated with the rest, so it should go in with the rest of the information in a box.

    I’m chipping away at this– will get back to you with the results.

    Hi bwesty, good luck, let me know how it goes. For the taxonomies there aren’t really rules, only good practices. So using them depends on what you are using them for.

    Let us know how you’re doing 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Post Type, Cateogry, Taxonomies, and Fields– Which to Use for What Information?’ is closed to new replies.