• FL
    multiple category selection


    if you create a new campaign (the form in the frontend), you can only select one category. I want give the user the posibility, to select more than one (like in the backend -> products, there you can select more than one via checkboxes).

    I tried something. Is this code correct?

    $html .= '<div class="wpneo-single">';
        $html .= '<div class="wpneo-name">'.__( "Category" , "wp-crowdfunding" ).'</div>';
        $html .= '<div class="wpneo-fields">';
    	$cat_args = array(
    		'taxonomy' => 'product_cat',
    		'hide_empty' => false,
    	//Get is Crowdfunding Categories only
    	$is_only_crowdfunding_categories = get_option('seperate_crowdfunding_categories');
    	if ('true' === $is_only_crowdfunding_categories){
    		$cat_args['meta_query'] = array(
    				'key' => '_marked_as_crowdfunding',
    				'value' => '1'
    	$all_cat = get_terms($cat_args );
    	$category = explode(", ", $category);
        foreach ($all_cat as $value) {
            $selected = (in_array($value->name, $category)) ? 'selected':'';
            $html .= '<input type="checkbox" name="wpneo-form-category[]" '.$selected.' value="'.$value->slug.'">'.$value->name.'</option>';
        $html .= '<small>'.__("Select your campaign category","wp-crowdfunding").'</small>';
        $html .= '</div>';
        $html .= '</div>';

    and in includes/woocommerce/class-wpneo-frontend-campaign-submit-form.php

    if( $category != '' ){
                        <del datetime="2019-05-14T19:53:17+00:00">$cat = explode(' ',$category );</del>
                        wp_set_object_terms( $post_id , $cat, 'product_cat',true );

    I also want to add attributes from the products (only one selectable). Can you tell me how I can add this in the Form?


    4 Replies

You must be logged in to reply to this topic.