Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress: Difference between "Custom Field", "Meta Box", and "Taxonomy"

This may be a trivial question, but I'm a little confused about the difference between "Custom Field", "Meta Box", and "Taxonomy" in Wordpress.

For example, if I'm going to create a custom post type called "Movie" with additional fields of "Actor", and "Genre", what would those additional fields be called?

like image 913
farjam Avatar asked Mar 18 '13 20:03

farjam


People also ask

What is custom meta box in WordPress?

What is a Custom Meta Box? Custom meta boxes allow users to add additional information to posts, pages and custom post types, apart from the default set of information that WordPress takes using default meta boxes. Plugins and Themes can use custom meta boxes to take additional structured user input.

What is custom post type and taxonomy in WordPress?

A WordPress taxonomy is a way to organize groups of posts and custom post types. The word taxonomy comes from the biological classification method called Linnaean taxonomy. By default, WordPress comes with two taxonomies called categories and tags. You can use them to organize your blog posts.

What is a WordPress custom field?

Custom fields are a somewhat more advanced WordPress feature, which lets you add extra information to certain posts. That information is called 'metadata. ' Custom fields and metadata are of particular use to developers, who can use them to extend posts with all sorts of coding.


2 Answers

  • A "meta box" is one of the various draggable and repositionable boxes available on the Post or Page editing screen (among other screens). There are several by default, such as the Formats, Tags, and Category boxes. A plugin can add meta boxes to be used for whatever purpose they need them, and meta boxes can both have information and receive input. Meta boxes can, and are, used for the following things, but they are not limited to that. They basically are user interface pieces. Wrappers for individual sections of the interface on the post editing screens.

  • A "custom field" is another name for what is better called "post metadata". Essentially, it's a key/value storage for posts that can be used by plugins or themes or directly by users for whatever purpose they need it. It can store arbitrary data about a post to be used in various ways. For example, if posts were about products for sale, then a piece of meta information for it might be "price" and "$9.95".

  • A "Taxonomy" is the generic term for a method of grouping posts together. A "category" is a taxonomy. So are "tags". To better explain taxonomy, if I was grouping together cars, then I might have a custom taxonomy called "color" and would group cars as "blue", "red", "black". Then I might also have a different taxonomy called "manufacturer" and group cars as "Ford", "Toyota", "Chevy", etc. The important difference between post-metadata and taxonomies is that with the taxonomy, the grouping itself is the most important thing, while with metadata, the actual value matters. I might want to see a lot of blue cars in a list, but I wouldn't take the value of "blue" and try to do something with it. Whereas with price, I might try to figure out the tax from it, or order the cars from lowest to highest price.

like image 83
Otto Avatar answered Oct 13 '22 11:10

Otto


Custom Fields and Meta Boxes are essentially the same, they allow you to store extra data/information in the postmeta table in the database. The data is stored in a key/value pair. And are attached to the post or page by id. Using the add_post_meta function.

add_post_meta($ID, 'name_of_data_to_store', 'value_of_that_data');

The key difference is that Custom Fields are native to wordpress so each post/page has them built-in.

But if you want create a Theme Options page you probably will want to use Meta Box to create the same results as Custom Fields provide natively.

For example, if I'm going to create a custom post type called "Movie" with additional fields of "Actor", and "Genre", what would those additional fields be called?

Actor and Genre could be the Taxonomy or ways of grouping items together wordpress by default has a few called Category, Tags, and Link Categories

more information on taxonomies found here.

like image 41
David Chase Avatar answered Oct 13 '22 10:10

David Chase