0

My current php code is as below

<?php
   //Select Paper Colour
   $paperColours = get_terms( array( 'taxonomy' => 'papercolour', 'order_by' => 'slug', 'hide_empty' => 0) );
                            
 if( !empty( $paperColours ) && !is_wp_error( $paperColours ) ) {
     echo "<select class='papercolour' name='papercolour' required='required' multiple>";
         foreach ( $paperColours as $paperColour ) {
         echo "<option value='".$paperColour->term_id."'>". $paperColour->name ."</option>";
     }
     echo "</select><!--projecttype-->";
 }

    if (isset( $_POST['papercolour']) {
    $papCol = $_POST['papercolour'];
    $papCol_ids = array($papCol);
    $papCol_ids = array_map( 'intval', $papCol_ids );
    $papCol_ids = array_unique( $papCol_ids );
    $papCols = wp_set_object_terms( $post_id, $papCol_ids, 'papercolour', $append = true );
}

?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.