0

I would like to save each value like this al_ttl_1...al_ttl_2 and how I can display it?

Actualy Im using this code to save all value. With the code below I can't see the custom field on backend ( it's working good to display everything ) but I want to save each value separatly (like ACF, i don't want to use plugin)

Hope you understand :)

    //Data Rows Save
    $old = get_post_meta($post_id, 'data_rows', true);
    $new = array();
    $ah_ttl = $_POST['al_ttl'];
    $ah_tmp = $_POST['al_tmp'];
    $count = count( $ah_ttl );
    for ( $i = 0; $i < $count; $i++ ) {
        if ( $ah_ttl[$i] != '' ) :
            $new[$i]['al_ttl'] = stripslashes( strip_tags( $ah_ttl[$i] ) );
            $new[$i]['al_tmp'] = stripslashes( $ah_tmp[$i] );

        endif;
    }

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

    }

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.