Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5972569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:40:35+00:00 2026-05-22T20:40:35+00:00

I got a custom post type, with a form for storing some data (name,

  • 0

I got a custom post type, with a form for storing some data (name, url) to display in a template.

What I want to know is how can I store those values in an array?

An example of my code:

<? function files_metadata(){  
        global $post; 
        $custom = get_post_custom($post->ID);  
        $name = $custom["name"][0];
        $url = $custom["url"][0];

        echo '<input type="hidden" name="files_metadata" id="files_metadata" value="' .wp_create_nonce('files_m'). '" />'; ?>  

<label>Name: </label><br/>
<input id="name" name="name" value="<?php echo $name; ?>" />
<label>Url: </label><br/>
<input id="url" name="url" value="<?php echo $url; ?>" />

<? function save_meta_files($post_id) {  
        if (!wp_verify_nonce($_POST['files_metadata'], 'files_m')) return $post_id;
        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return $post_id;

        update_post_meta($post_id, "name", $_POST["url"]);   
        update_post_meta($post_id, "url", $_POST["url"]); 
    }  

add_action('save_post', 'save_meta_files'); ?> 

To this I want to add something like…

$url = $custom["url"][0];
$url2 = $custom["url"][1];
$url3 = $custom["url"][2];

<input id="url" name="url[0]" value="<?php echo $url; ?>" />
<input id="url2" name="url[1]" value="<?php echo $url2; ?>" />
<input id="url3" name="url[2]" value="<?php echo $url3; ?>" />

update_post_meta($post_id, "url", $_POST["url"][0]); 
update_post_meta($post_id, "url2", $_POST["url"][1]); 
update_post_meta($post_id, "url3", $_POST["url"][2]); 

…but that actually works…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:40:35+00:00Added an answer on May 22, 2026 at 8:40 pm

    A passed array will be serialized into a string: http://codex.wordpress.org/Function_Reference/update_post_meta

    update_post_meta(
        $post_id,
        'files_metadata',
        array(
            'name1' => $_POST['name1'],
            'url1' => $_POST['url1']
            'name2' => $_POST['name2'],
            'url2' => $_POST['url2']
        )
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a custom data type for Umbraco based on Tim's Blog Post:
hello im trying to set custom errors. i got a form. actions to post.php
I've got collection of objects I want use in my custom tag.But I can
I've got a custom attribute that I want to apply to my base abstract
I've got some custom metadata to put into a PNG file. It's being saved
I have a custom Http Handler which manipulates HTTP POST and GET. I got
I am working on some custom post types. I finished the first one and
I've got a custom field for my client's site to display a custom tag.
I've created a custom post type with categories and sub categories, what I need
I've got a nice power-shell driven post-build script that does some magic mumbo-jumbo for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.