How to register array of values -<input name="myvalue[]"> (2 posts)

  1. de77
    Posted 6 years ago #

    Can anyone tell me?
    I want to have on Settins page few fields with the same name:

    <input name="myvalue[]">
    <input name="myvalue[]">

    How to register, how to load values?

  2. alieneila
    Posted 6 years ago #

    I know this post is a month old, but maybe you or someone else is still looking...

    add_action( 'admin_init', 'myRegisterFunction' );
    function myRegisterFunction() {
    	register_setting( 'my-setting-group', 'my_serialized_setting' );

    You can access the values with get_option, it will be an array if you do use the form options with the value names as arrays...

    $options = array();
    $options = get_option( "my_serialized_setting" );
    // Print the array
    // Print each value of array
    foreach ($options as $value) {
    	echo $value;

Topic Closed

This topic has been closed to new replies.

About this Topic