Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Adding terms to Taxonomy in wordpress

    • 0
    • 1
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 111
    Comment on it

    Welcome to Findnerd. We all knows we can build our own custom taxonomies and insert the terms in taxonomies. There is one function available to insert the terms in perticular taxonomy named wp_insert_terms which takes three parameters. First one is name of the term. You can simply build an array of different terms and set as first parameter in the function and second parameter will take name of the taxonomy for which you are going to add the terms. Third one is the array of the aguments which takes different arguments such as slug,description,parent,alias_of. Let's take an simple example.

    $parent_term_id = 34; // get numeric term id
    wp_insert_term(
      'Casey', // the term 
      'product', // the taxonomy
      array(
        'description'=> 'new player.',
        'slug' => 'casey',
        'parent'=> $parent_term_id
      )
    );
    

    In above example we build a term named casey which is a player name and also set the parent term.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: