Skip to main content
Commonmark migration
Source Link
  1. First, dd this code [] at the end of your form field name. So your field's name will be "test[]".

    First, dd this code [] at the end of your form field name. So your field's name will be "test[]".

    Example:

    <input type="text" name="test[]" value=""  size="60" />
    
  2. Use this way to save the value:

    $old = get_post_meta($post_id, 'your_meta_key', true);
    $newtest = array();
    $test = $_POST['test'];
    $count = count( $test );
    
    for ( $i = 0; $i < $count; $i++ ) {
        if ( $test[$i] != '' ) {
            $newtest[$i]['test'] = stripslashes( strip_tags( $test[$i] ) );
        }
    }
    
    if ( !empty( $newtest ) && $newtest != $old ) {
        update_post_meta( $post_id, 'repeatable_fields', $newtest );
    } elseif ( empty($newtest) && $old ) {
        delete_post_meta( $post_id, 'repeatable_fields', $old );
    }
    
  3. Showing your field with the saved values:

    $show_the_value = get_post_meta($post->ID, 'your_meta_key', true);
    if ($show_the_value) {
        foreach ($show_the_value as $value) { ?>
            <input type="text" name="test[]" value="<?php if($value['test'] != '') echo  $value['test']; ?>"  size="60" />
        <?php }
    }
    

Example:

    <input type="text" name="test[]" value=""  size="60" />
  1. Use this way to save the value:

    $old = get_post_meta($post_id, 'your_meta_key', true);
    $newtest = array();
    $test = $_POST['test'];
    $count = count( $test );
    
    for ( $i = 0; $i < $count; $i++ ) {
        if ( $test[$i] != '' ) {
            $newtest[$i]['test'] = stripslashes( strip_tags( $test[$i] ) );
        }
    }
    
    if ( !empty( $newtest ) && $newtest != $old ) {
        update_post_meta( $post_id, 'repeatable_fields', $newtest );
    } elseif ( empty($newtest) && $old ) {
        delete_post_meta( $post_id, 'repeatable_fields', $old );
    }
    
  2. Showing your field with the saved values:

    $show_the_value = get_post_meta($post->ID, 'your_meta_key', true);
    if ($show_the_value) {
        foreach ($show_the_value as $value) { ?>
            <input type="text" name="test[]" value="<?php if($value['test'] != '') echo  $value['test']; ?>"  size="60" />
        <?php }
    }
    
  1. First, dd this code [] at the end of your form field name. So your field's name will be "test[]".

Example:

    <input type="text" name="test[]" value=""  size="60" />
  1. Use this way to save the value:

    $old = get_post_meta($post_id, 'your_meta_key', true);
    $newtest = array();
    $test = $_POST['test'];
    $count = count( $test );
    
    for ( $i = 0; $i < $count; $i++ ) {
        if ( $test[$i] != '' ) {
            $newtest[$i]['test'] = stripslashes( strip_tags( $test[$i] ) );
        }
    }
    
    if ( !empty( $newtest ) && $newtest != $old ) {
        update_post_meta( $post_id, 'repeatable_fields', $newtest );
    } elseif ( empty($newtest) && $old ) {
        delete_post_meta( $post_id, 'repeatable_fields', $old );
    }
    
  2. Showing your field with the saved values:

    $show_the_value = get_post_meta($post->ID, 'your_meta_key', true);
    if ($show_the_value) {
        foreach ($show_the_value as $value) { ?>
            <input type="text" name="test[]" value="<?php if($value['test'] != '') echo  $value['test']; ?>"  size="60" />
        <?php }
    }
    
  1. First, dd this code [] at the end of your form field name. So your field's name will be "test[]".

    Example:

    <input type="text" name="test[]" value=""  size="60" />
    
  2. Use this way to save the value:

    $old = get_post_meta($post_id, 'your_meta_key', true);
    $newtest = array();
    $test = $_POST['test'];
    $count = count( $test );
    
    for ( $i = 0; $i < $count; $i++ ) {
        if ( $test[$i] != '' ) {
            $newtest[$i]['test'] = stripslashes( strip_tags( $test[$i] ) );
        }
    }
    
    if ( !empty( $newtest ) && $newtest != $old ) {
        update_post_meta( $post_id, 'repeatable_fields', $newtest );
    } elseif ( empty($newtest) && $old ) {
        delete_post_meta( $post_id, 'repeatable_fields', $old );
    }
    
  3. Showing your field with the saved values:

    $show_the_value = get_post_meta($post->ID, 'your_meta_key', true);
    if ($show_the_value) {
        foreach ($show_the_value as $value) { ?>
            <input type="text" name="test[]" value="<?php if($value['test'] != '') echo  $value['test']; ?>"  size="60" />
        <?php }
    }
    
  1. First, dd this code [] at the end of your form field name. So your field's name will be "test[]". Example:
 

Example:

    <input type="text" name="test[]" value=""  size="60" />
  1. Use this way to save the value:

    $old = get_post_meta($post_id, 'your_meta_key', true); $newtest = array(); $test = $_POST['test']; $count = count( $test );

    for ( $i = 0; $i < $count; $i++ ) { if ( $test[$i] != '' ) : $newtest[$i]['test'] = stripslashes( strip_tags( $test[$i] ) ); endif; }

    if ( !empty( $newtest ) && $newtest != $old ) update_post_meta( $post_id, 'repeatable_fields', $newtest ); elseif ( empty($newtest) && $old ) delete_post_meta( $post_id, 'repeatable_fields', $old );

    $old = get_post_meta($post_id, 'your_meta_key', true);
    $newtest = array();
    $test = $_POST['test'];
    $count = count( $test );
    
    for ( $i = 0; $i < $count; $i++ ) {
        if ( $test[$i] != '' ) {
            $newtest[$i]['test'] = stripslashes( strip_tags( $test[$i] ) );
        }
    }
    
    if ( !empty( $newtest ) && $newtest != $old ) {
        update_post_meta( $post_id, 'repeatable_fields', $newtest );
    } elseif ( empty($newtest) && $old ) {
        delete_post_meta( $post_id, 'repeatable_fields', $old );
    }
    
  2. Showing your field with the saved values:

    $show_the_value = get_post_meta($post->ID, 'your_meta_key', true);

    if ($show_the_value) {

    foreach ($show_the_value as $value) {

    $show_the_value = get_post_meta($post->ID, 'your_meta_key', true);
    if ($show_the_value) {
        foreach ($show_the_value as $value) { ?>
            <input type="text" name="test[]" value="<?php if($value['test'] != '') echo  $value['test']; ?>"  size="60" />
        <?php }
    }
    

    }

    }

  1. First, dd this code [] at the end of your form field name. So your field's name will be "test[]". Example:
 
  1. Use this way to save the value:

    $old = get_post_meta($post_id, 'your_meta_key', true); $newtest = array(); $test = $_POST['test']; $count = count( $test );

    for ( $i = 0; $i < $count; $i++ ) { if ( $test[$i] != '' ) : $newtest[$i]['test'] = stripslashes( strip_tags( $test[$i] ) ); endif; }

    if ( !empty( $newtest ) && $newtest != $old ) update_post_meta( $post_id, 'repeatable_fields', $newtest ); elseif ( empty($newtest) && $old ) delete_post_meta( $post_id, 'repeatable_fields', $old );

  2. Showing your field with the saved values:

    $show_the_value = get_post_meta($post->ID, 'your_meta_key', true);

    if ($show_the_value) {

    foreach ($show_the_value as $value) {

     <input type="text" name="test[]" value="<?php if($value['test'] != '') echo  $value['test']; ?>"  size="60" />
    

    }

    }

  1. First, dd this code [] at the end of your form field name. So your field's name will be "test[]".

Example:

    <input type="text" name="test[]" value=""  size="60" />
  1. Use this way to save the value:

    $old = get_post_meta($post_id, 'your_meta_key', true);
    $newtest = array();
    $test = $_POST['test'];
    $count = count( $test );
    
    for ( $i = 0; $i < $count; $i++ ) {
        if ( $test[$i] != '' ) {
            $newtest[$i]['test'] = stripslashes( strip_tags( $test[$i] ) );
        }
    }
    
    if ( !empty( $newtest ) && $newtest != $old ) {
        update_post_meta( $post_id, 'repeatable_fields', $newtest );
    } elseif ( empty($newtest) && $old ) {
        delete_post_meta( $post_id, 'repeatable_fields', $old );
    }
    
  2. Showing your field with the saved values:

    $show_the_value = get_post_meta($post->ID, 'your_meta_key', true);
    if ($show_the_value) {
        foreach ($show_the_value as $value) { ?>
            <input type="text" name="test[]" value="<?php if($value['test'] != '') echo  $value['test']; ?>"  size="60" />
        <?php }
    }
    
deleted 4 characters in body
Source Link
Ari
  • 1.2k
  • 1
  • 17
  • 28
  1. First, dd this code [] at the end of your form field name. So your field's name will be "test[]". Example:

  2. Use this way to save the value:

    $old = get_post_meta($post_id, 'your_meta_key', true); $newtest = array(); $test = $_POST['test']; $count = count( $test );

    for ( $i = 0; $i < $count; $i++ ) { if ( $test[$i] != '' ) : $newtest[$i]['test'] = stripslashes( strip_tags( $test[$i] ) ); endif; }

    if ( !empty( $newtest ) && $newtest != $old ) update_post_meta( $post_id, 'repeatable_fields', $newtest ); elseif ( empty($newtest) && $old ) delete_post_meta( $post_id, 'repeatable_fields', $old );

  3. Showing your field with the saved values:

    $show_the_value = get_post_meta($post->ID, 'your_meta_key', true);

    if ($show_the_value) {

    foreach ($show_the_value as $value) {

     <input type="text" name="test[]" value="<?php if($value['test'] != '') echo  $value['test']; ?>"  size="60" />
    

    }

    }

    First, dd this code [] at the end of your form field name. So your field's name will be "test[]". Example:
  1. Use this way to save the value:

    $old = get_post_meta($post_id, 'your_meta_key', true); $newtest = array(); $test = $_POST['test']; $count = count( $test );

    for ( $i = 0; $i < $count; $i++ ) { if ( $test[$i] != '' ) : $newtest[$i]['test'] = stripslashes( strip_tags( $test[$i] ) ); endif; }

    if ( !empty( $newtest ) && $newtest != $old ) update_post_meta( $post_id, 'repeatable_fields', $newtest ); elseif ( empty($newtest) && $old ) delete_post_meta( $post_id, 'repeatable_fields', $old );

  2. Showing your field with the saved values:

    $show_the_value = get_post_meta($post->ID, 'your_meta_key', true);

    if ($show_the_value) {

    foreach ($show_the_value as $value) {

     <input type="text" name="test[]" value="<?php if($value['test'] != '') echo  $value['test']; ?>"  size="60" />
    

    }

    }

  1. First, dd this code [] at the end of your form field name. So your field's name will be "test[]". Example:

  2. Use this way to save the value:

    $old = get_post_meta($post_id, 'your_meta_key', true); $newtest = array(); $test = $_POST['test']; $count = count( $test );

    for ( $i = 0; $i < $count; $i++ ) { if ( $test[$i] != '' ) : $newtest[$i]['test'] = stripslashes( strip_tags( $test[$i] ) ); endif; }

    if ( !empty( $newtest ) && $newtest != $old ) update_post_meta( $post_id, 'repeatable_fields', $newtest ); elseif ( empty($newtest) && $old ) delete_post_meta( $post_id, 'repeatable_fields', $old );

  3. Showing your field with the saved values:

    $show_the_value = get_post_meta($post->ID, 'your_meta_key', true);

    if ($show_the_value) {

    foreach ($show_the_value as $value) {

     <input type="text" name="test[]" value="<?php if($value['test'] != '') echo  $value['test']; ?>"  size="60" />
    

    }

    }

  1. First, dd this code [] at the end of your form field name. So your field's name will be "test[]". Example:
  1. Use this way to save the value:

    $old = get_post_meta($post_id, 'your_meta_key', true); $newtest = array(); $test = $_POST['test']; $count = count( $test );

    for ( $i = 0; $i < $count; $i++ ) { if ( $test[$i] != '' ) : $newtest[$i]['test'] = stripslashes( strip_tags( $test[$i] ) ); endif; }

    if ( !empty( $newtest ) && $newtest != $old ) update_post_meta( $post_id, 'repeatable_fields', $newtest ); elseif ( empty($newtest) && $old ) delete_post_meta( $post_id, 'repeatable_fields', $old );

  2. Showing your field with the saved values:

    $show_the_value = get_post_meta($post->ID, 'your_meta_key', true);

    if ($show_the_value) {

    foreach ($show_the_value as $value) {

     <input type="text" name="test[]" value="<?php if($value['test'] != '') echo  $value['test']; ?>"  size="60" />
    

    }

    }

Source Link
Ari
  • 1.2k
  • 1
  • 17
  • 28
Loading