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

Haluk Karamete halukkaramete at gmail.com
Sat Apr 7 16:00:04 UTC 2012


>>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?

I'm just trying to understand the process. Please verify the following
understanding is correct.

Suppose there are two plugins whose sole jobs are to create custom
taxonomies.
And I happened to install and activate both of them. ( sidenote: It does
not matter which particular plugins they are - because, I don't have them
to begin with and it's irrelevant to the question I have. Just imagine two
top two custom taxonomy creation plugs in. )

Say, I create a taxonomy called "Audience" - using one of those plugins.
And I pass the description of the Audiance taxonomy as "Description XYZ"
using that plugins UI.
Then I adjust my template file to output the description of the Audience
taxonomy. My site visitors should be able to see "Description XYZ". Right?

Then I go ahead and open up the second plug ins UI.

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?

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?




>> The only data which is stored in the database is the actual Terms,
which are stored in the 'terms' table. The relationship between a
Term->Post object is stored in the 'term_relationships' table, and the
relationship linking a term to it's taxonomy is in the 'term_taxonomy'
table - Only the slug of the Taxonomy is stored in the database, in
your case, it would be 'genre' or 'writer' but they'll only be there
if you insert a Term that's actually in that taxonomy, the code you're
using inserts a category only.

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?



On Fri, Apr 6, 2012 at 5:46 PM, Dion Hulse (dd32) <wordpress at dd32.id.au>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.
>
> The only data which is stored in the database is the actual Terms,
> which are stored in the 'terms' table. The relationship between a
> Term->Post object is stored in the 'term_relationships' table, and the
> relationship linking a term to it's taxonomy is in the 'term_taxonomy'
> table - Only the slug of the Taxonomy is stored in the database, in
> your case, it would be 'genre' or 'writer' but they'll only be there
> if you insert a Term that's actually in that taxonomy, the code you're
> using inserts a category only.
>
> See http://codex.wordpress.org/Database_Description#Table:_wp_termsonwards
>
> On 7 April 2012 10:41, Haluk Karamete <halukkaramete at gmail.com> wrote:
> > but registered where? in a text file?
> >
> > I run the code in a stand alone php page, not in some theme's
> > functions.php.
> >
> > the exact page goes like this,
> >
> > when you say registered? I'm curious to know where it is registered,
> > memory?
> >
> > <?php
> >
> > error_reporting (E_ALL);
> >
> >
> > $full_path_to_wp_header = "F:\inetpub\wwwroot\... mypath here...
> > \wp-load.php";
> >
> > include ($full_path_to_wp_header);
> >
> >
> >
> > define('WP_USE_THEMES', false);
> >
> > echo bloginfo();
> >
> > if(0):
> > $arg = array('description' => "my description", 'parent' => "");
> > $new_cat_id = wp_insert_term("Religion", "category", $arg);
> > var_dump( $new_cat_id);
> > endif;
> >
> >  $labels = array(
> >    'name' => _x( 'Genres', 'taxonomy general name' ),
> >    'singular_name' => _x( 'Genre', 'taxonomy singular name' ),
> >    'search_items' =>  __( 'Search Genres' ),
> >    'all_items' => __( 'All Genres' ),
> >    'parent_item' => __( 'Parent Genre' ),
> >    'parent_item_colon' => __( 'Parent Genre:' ),
> >    'edit_item' => __( 'Edit Genre' ),
> >    'update_item' => __( 'Update Genre' ),
> >    'add_new_item' => __( 'Add New Genre' ),
> >    'new_item_name' => __( 'New Genre Name' ),
> >    'menu_name' => __( 'Genre' ),
> >  );
> >
> >  register_taxonomy('genre',array('book'), array(
> >    'hierarchical' => true,
> >    'labels' => $labels,
> >    'show_ui' => true,
> >    'query_var' => true,
> >    'rewrite' => array( 'slug' => 'genre' ),
> >  ));
> >
> >  // Add new taxonomy, NOT hierarchical (like tags)
> >  $labels = array(
> >    'name' => _x( 'Writers', 'taxonomy general name' ),
> >    'singular_name' => _x( 'Writer', 'taxonomy singular name' ),
> >    'search_items' =>  __( 'Search Writers' ),
> >    'popular_items' => __( 'Popular Writers' ),
> >    'all_items' => __( 'All Writers' ),
> >    'parent_item' => null,
> >    'parent_item_colon' => null,
> >    'edit_item' => __( 'Edit Writer' ),
> >    'update_item' => __( 'Update Writer' ),
> >    'add_new_item' => __( 'Add New Writer' ),
> >    'new_item_name' => __( 'New Writer Name' ),
> >    'separate_items_with_commas' => __( 'Separate writers with commas' ),
> >    'add_or_remove_items' => __( 'Add or remove writers' ),
> >    'choose_from_most_used' => __( 'Choose from the most used writers' ),
> >    'menu_name' => __( 'Writers' ),
> >  );
> >
> >  register_taxonomy('writer','book',array(
> >    'hierarchical' => false,
> >    'labels' => $labels,
> >    'show_ui' => true,
> >    'update_count_callback' => '_update_post_term_count',
> >    'query_var' => true,
> >    'rewrite' => array( 'slug' => 'writer' ),
> >  ));
> >
> >  echo "<p>Done!";
> >
> > $taxonomies=get_taxonomies('','names');
> > foreach ($taxonomies as $taxonomy ) {
> >  echo '<p>'. $taxonomy. '</p>';
> > }
> >
> > ?>
> > _______________________________________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> _______________________________________________
> 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