Skip to content

Instantly share code, notes, and snippets.

/taxonomy.php Secret

Created May 8, 2013 09:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/dc2b058d7a36ae57c240 to your computer and use it in GitHub Desktop.
Save anonymous/dc2b058d7a36ae57c240 to your computer and use it in GitHub Desktop.
Custom taxonomy for tagging
<?php
/* Preamble */
A tag has 8 parts - Tier 1, Tier 2, Brand, Colour, Material, Pattern, Price, XY (coordinates for tag position)
There is currently no limit to the amount of tags.
/* Approach 1 - create a custom taxonomy for each tag part and for each tag create an array value */
wp_set_object_terms(123, array('dress','shoes'), tag_t1)
wp_set_object_terms(123, array('high-waisted','high-heel'), tag_t2)
wp_set_object_terms(123, array('topshop','next'), tag_brand)
wp_set_object_terms(123, array('red','blue'), tag_colour)
wp_set_object_terms(123, array('leather','suede'), tag_material)
wp_set_object_terms(123, array('gingham','plain'), tag_pattern)
wp_set_object_terms(123, array('42.00','50.00'), tag_price)
wp_set_object_terms(123, array('56,79','89,84'), tag_xy)
/* Approach 2 - create 1 custom taxonomy which includes a nested array of each tag and corresponding parts */
$tags = array(
array(
't1'=>'dress',
't2'=>'high-waisted',
'brand'=>'topshop',
'colour'=>'red',
'material' => 'leather',
'pattern' => 'gingham',
'price' => '42.00',
'xy' => '56,79'
),
array(
't1'=>'shoes',
't2'=>'high-heel',
'brand'=>'next',
'colour'=>'blue',
'material' => 'suede',
'pattern' => 'plain',
'price' => '50.00',
'xy' => '89,84'
)
)
wp_set_object_terms(123,$tags,tag);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment