[wp-hackers] CPT VS Plugin

Mike Schinkel mikeschinkel at newclarity.net
Wed Nov 16 18:51:46 UTC 2011

Hi Leo:

Here's how I might do it (assuming I understood your requirements and that you don't need lots of info about a teacher):

Custom Taxonomy:

	- Teacher (or People) (Could potentially also want to use Users or Custom Post Types here, depending on your requirements.)
	- City(maybe?)

Not sure about Students. Could be:

	- Users
	- Custom Taxonomy (Student or just People)
	- Custom Post Type  (Student or People)
Custom Post Types/Custom Fields:

	- Course
		- Applicable Teachers
		- All other info about a course.

	- Class
		- Course ($course->ID => $class->post_parent)
		- Teacher
		- City
		- Date/Time
		- All other info about a class.
		- Student List

Basically Taxonomies are best when you really want to use them as "tags" to filter your posts, i.e. to get a list of all Class posts for Teacher.

Custom Post Types are best when you need lots of additional information to go along with an item besides a simple name and description. You can added custom fields to CPTs and you can use categories, tags or custom taxonomies with them.

Users are best when the people your system tracks are primarily users of your system.

Custom Fields for CPTs is best when the data you need to keep track is related but simple, and you don't need build in "archive pages" for them, i.e. Prerequisites for a Course or Directions to a Class.

You can also mirror each of these, so you could have a Person CPT that mirrors a User, or a Teacher CPT that mirrors a Teacher Taxonomy, but mirroring can be fragile and takes work to get it right.

You can relate items in WordPress is a number of ways; 1-to-many CPTs can be handled with the post_parent field. For many-to-many you can relate CPTs or other items via shared taxonomy terms i.e. both Course and Class could use be related by terms in a "Topic" taxonomy, i.e. "PHP Development" could be a shared Topic term. But there is no proper many-to-many functionality built into WordPress; you have to build custom tables for that.

Hope this helps.

P.S. BTW, we are building a GPL plugin framework, probably ready for beta by end of year, that would make this really easy. It will include functionality for all of this, including many-to-many relationships via a 'wp_relationships' table...

On Nov 16, 2011, at 12:25 PM, Leo Baiano wrote:

> Personally, I would like you to help us to start thinking about a course
> management system that will need to implement a customersite. My main
> doubt is whether the best way to do this is using CPT and taxonomies or
> create separate tables and develop a pluginlike it.
> So they can help me I will explain the context.
> In the course management system I have classes and courses. Classes
> are formed by the junction of the course + city where the course is going
> to happen. It is important to understand that each class has its own
> characteristics inheriting the course only the name and description, but
> the classes, teachers, number of jobs, etc. ... are directly related
> to class, where to register a new class I need to inform the city,
> state, and course specific information in this class.
> Besides, I have teachers, they are connected directly to the classroom
> (information about the class that will be given) and the lessonis linked
> directly to class.
> I also have students that are linked to class.
> Are there any other information but I believe they are quieter, which has
> left me in doubt regarding the use of the CPT is on accountof relationships
> and the difficulty in defining what taxonomies and which would be
> linked CPT.
> For example, the relationship between the city, the class and course. Then
> there is the relationship with the teacher and this classwith the class.
> Well, I hope you managed to explain myself properly, I rode the EER but
> the name of the tables and fields are in Portuguese, I do not know they
> could understand, but if someone willing to help me think this work ....
> Using CPT I have the advantage of some features ready to use WP as
> a friendly URL for example, but
> apparently lost a little respectin the relationship of the system entities.
> -- 
> Amplexos,
> Leo Baiano
> http://www.leobaiano.com
> http://www.blog.ljunior.com
> http://www.mcelebridades.com
> http://www.twitter.com/leobaiano
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers

More information about the wp-hackers mailing list