[wp-hackers] where does the custom taxonomy info is kept?

Dion Hulse (dd32) wordpress at dd32.id.au
Sun Apr 8 01:24:35 UTC 2012

On 8 April 2012 02:00, Haluk Karamete <halukkaramete at gmail.com> wrote:
>>>register_taxonomy must be called on every page load, the data is
> "registered" for the current page load only, and must be called before
> anything that needs to use it. The best place is a hook attached to
> 'init' usually.
> I'm not going to question what the wisdom behind that approach is, though I
> found it difficult to understand why such a fundamental piece of
> information is not kept in the database? and it is kept in the server
> memory?

Taxonomies, Post Statuses, and Custom Post Types are not the type of
data that needs persistent storage, in most cases, in order to make
either of these functionalities useful, extra code is required (a more
custom meta box, theme display, hooks to control the way the data is
saved (pre-processing), etc) to control the way the item acts, combine
that with the translation data needed, and you suddenly don't actually
have any data that should be stored persistently.
Remember, that the register_*() calls can go into a themes
functions.php file too.
Having it in code also leads to portability, you can move a theme, or
a plugin to another site, and any custom items it requires will be
active there as well, rather than the user having to run a secondary
install process.

> Question 1: Will I be able to see the audience taxonomy that the first plug
> in created?
> Question 2: If I am able to see the audience taxonomy that the first plugin
> has created && I am able to modify the description from "Description XYZ"
> to "Description ABC" (using the second plugins UI), would I be able to
> effect the wordpress page that my visitors see so that my visitors now read
>  the "Description ABC" as opposed to the original "Description XYZ"? Or
> does this depend on which plugin is active at the moment? What if they both
> are active? If I happened to remove those two plugins, would all my
> taxonomy-term associations with my posts will be gone and my site
> functionality totally suffer from it?

Chances are, 2 plugins whose sole purpose in life is to create a UI to
add a custom taxonomy will be incompatible with eachother, However not
in the way you probably expect.
The incompatibility will be in the data storage, If 2 plugins were
running, they'd both be able to register/edit the taxonomies they know
about (Ie. those that were created in it).
the plugins who create a UI to create taxonomies/post types are not
designed to be used as -the- way of creating a tax/cpt, their purpose
in life is to make it faster to create an example if anything, most of
the ones I have seen (well the popular ones at least) also provide the
PHP code which you should add to your site once you've finished
checking the checkboxes/etc.

> How do I make sure that once I create taxonomy and start using it, it
> always stays there.
> With the limited knowledge I have, I'm guessing either stick to one plug in
> and keep it active all the time, or write your own global_functions.php
> file and make sure all my template's functions.php files have an include
> reference to it and keep my register_taxonomy functions in
> the global_functions.php?

You'll need to do one of 3 things:
 * Create a plugin for your site, and put your site-specific code in
there (or code you want to include on all your sites)
 * If the code is theme-specific, put it in your themes functions.php
- If you're using a ready-made theme, consider making a Child Theme of
it - http://codex.wordpress.org/Child_Themes
 * Create a mu-plugin, mu-plugins are commonly called 'Must Use
Plugins' they're loaded always, but act the same as normal plugins,
simply drop a .php file into wp-content/mu-plugins and it'll be loaded

> Thank you Dion as always you clarify it very well. If I no longer have the
> register_taxonomy function running ( when wordpress loads or inits ), can
> the posts still be pulled by that taxonomy & term?

If you don't have a register_taxonomy() call, then WordPress will not
know about the taxonomy, and as a result, won't be able to query for
It comes from 2 reasons, It no longer knows what the query variable
for it is (in the URL), and it no longer knows if it should be
publicly accessible (You can create taxonomies which should never be
accessed from the front end, and are simply there to control a theme
or plugin).
I also missed a question earlier, Data is NOT deleted if you don't
have the register_Taxonomy() call, the term data, and all relationship
data remains in the database, it just won't be accessed again until
the register_taxonomy() call is made again, this is also why you
should call it on the init hook, that way it's available to all
plugins/theme functions which run after it.

More information about the wp-hackers mailing list