Hello Reader's! if you are new to wordpress development and need to add more custom fields in category, Then you can learn it from the code below:-
Step:1-
Open the file functinon.php and add the following code in it.
add_action( 'category_edit_form_fields', 'dot_img_custom_fields', 10, 2 );
function dot_img_custom_fields($tag)
{   
    $img_id = $tag->term_id; // Get the ID of the term you're editing
    $img_url = get_option( "taxonomy_term_$img_id" ); // Do the check
    ?>
    <tr class="form-field">
        <th scope="row" valign="top">
            <label for="extra_information"><?php _e('Insert Featured Image Link'); ?></label>
        </th>
        <td >
            <input type="text" name="img_url[get_img]" size="7" style="width:95%;" value="<?php echo $img_url['get_img'] ? $img_url['get_img'] : ''; ?>" placeholder="Link" />
        </td>
    </tr>
    <?php
}
// Save the changes made on the "faq_category" taxonomy, using our callback function  
add_action( 'edited_category', 'save_img_custom_custom_fields', 10, 2 );
// A callback function to save our extra taxonomy field(s)  
function save_img_custom_custom_fields( $term_id )
{  
    if ( isset( $_POST['img_url'] ) )
    {  
        $img_id = $term_id;  
        $img_url = get_option( "taxonomy_term_$img_id" );  
        $img_keys = array_keys( $_POST['img_url'] );  
            foreach ( $img_keys as $img_key ){  
            if ( isset( $_POST['img_url'][$img_key] ) ){  
                $img_url[$img_key] = $_POST['img_url'][$img_key];  
            }  
        }
        //save the option array  
        update_option( "taxonomy_term_$img_id", $img_url, $allowed );  
    }
} 
Now when you will see this added field in uploading the category. 
                       
                    
0 Comment(s)