Advertisement
Guest User

wordpress tagging taxonomy

a guest
May 3rd, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.15 KB | None | 0 0
  1. /* Approach 1 - create a taxonomy for each tag attribute and for each tag create an array value */
  2.  
  3. wp_set_object_terms(123, array('dress','shoes'), tag_t1)
  4. wp_set_object_terms(123, array('high-waisted','high-heel'), tag_t2)
  5. wp_set_object_terms(123, array('topshop','next'), tag_brand)
  6. wp_set_object_terms(123, array('red','blue'), tag_colour)
  7. wp_set_object_terms(123, array('leather','suede'), tag_material)
  8. wp_set_object_terms(123, array('gingham','plain'), tag_pattern)
  9. wp_set_object_terms(123, array('42.00','50.00'), tag_price)
  10. wp_set_object_terms(123, array('56,79','89,84'), tag_xy)
  11.  
  12. /* Approach 2 - create a tags taxonomy and includes a nested array of each tag and corresponding attributes  */
  13.  
  14. $tags = array(
  15.         array(
  16.             't1'=>'dress',
  17.             't2'=>'high-waisted',
  18.             'brand'=>'topshop',
  19.             'colour'=>'red',
  20.             'material' => 'leather',
  21.             'pattern' => 'gingham',
  22.             'price' => '42.00',
  23.             'xy' => '56,79'
  24.         ),
  25.         array(
  26.             't1'=>'shoes',
  27.             't2'=>'high-heel',
  28.             'brand'=>'next',
  29.             'colour'=>'blue',
  30.             'material' => 'suede',
  31.             'pattern' => 'plain',
  32.             'price' => '50.00',
  33.             'xy' => '89,84'
  34.         )
  35. )
  36.  
  37.  
  38. wp_set_object_terms(123,$tags,tag);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement