• Resolved Jacorre

    (@jacorre)


    I’ve been following this tutorial Revisited Creating Custom Write Panels in WordPress on creating a custom write panel and I’ve gotten it to appear successfully.

    My question is how do I get all of my previous posts with custom fields defined already to populate the new custom write panel?

    It would be easier to use the custom write panel for future posts, but if I have to go back and define the data in that format for previous posts, that would be one heck of an undertaking!

    Any suggestions are appreciated!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    if you make the $key the same as your old custom field $key it will be using that to show in the metabox.

    $key = "key";

    Thread Starter Jacorre

    (@jacorre)

    Thanks for the quick response.

    I thought that the variable $key at the top of the script was only being used to label the write panel?

    I am using the names of the custom fields I already have defined as the same names in the array to define the custom write panel fields.

    For example, I have a custom field called thumbnail.

    So in my array, I have:

    $key = "key";
    $meta_boxes = array(
    "thumbnail" => array(
    "name" => "thumbnail",
    "title" => "Thumbnail",
    "description" => "Enter the Thumbnail URL.")

    Are you saying that the $key value should be thumbnail?

    Moderator keesiemeijer

    (@keesiemeijer)

    I just read they store their $_POST data as a serialized array.
    in this tutorial they save the $_POST data as individual custom fields: http://www.deluxeblogtips.com/2010/05/howto-meta-box-wordpress.html
    Just remove the prefix from the custum field key (id) to let the metabox use your custom field key:
    so this:

    'fields' => array(
            array(
                'name' => 'Text box',
                'desc' => 'Enter something here',
                'id' => $prefix . 'text',
                'type' => 'text',
                'std' => 'Default value 1'
            )
        )

    will become this:

    'fields' => array(
            array(
                'name' => 'image',
                'desc' => 'Enter something here',
                'id' => 'thumbnail', // your custom field key
                'type' => 'text',
                'std' => 'Default value 1'
            )
        )

    Thread Starter Jacorre

    (@jacorre)

    I will give that a try thank you!

    Thread Starter Jacorre

    (@jacorre)

    Works great thank you!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Custom Fields and Custom Write Panel’ is closed to new replies.