Blog

Unserialize WordPress and Export with WP All Export

If you have WP All Export (by WP All Import) and you are trying to export database entries that are serialized, you can use the following PHP function to unserialize while exporting data.

If you are not using WP All Export, but do need a tidy function that will unserialize your data, this function is just what you’re looking for!

Unserialize Function

<?php
function data_deserialize($value){
$output = '';
$data = maybe_unserialize($value);
$data = $data[0];
foreach ($data as $key => $value){
$output .= $key.': '.$value.'
';
}
return $output;
}
?>

Placement

Here is a view of the drag-and-drop export builder that WP All Export provides. In this case, some values correlated to custom post meta that is serialized. The “member-interactions” field is one such post meta.

Unserialize data from WP All Export

You can place the function above in WP All Export by clicking on the value object in the drag-and-drop export builder. This will open the Edit Export Field dialogue. Check the box next to “Export the value returned by a PHP function” top open the Function Editor.

Enter the function name, and function, as depicted below. (Note, replace “your_function_name” with “data_deserialize,” or change the function name in both places to your liking.)

Unserialize data from WP All Export

The Function Editor directly alters a file stored on your website. The first time you add a function, the Function Editor will be blank. But when you add a function, it will be saved to the file. It will be visible when you open the editor in the future, for every field.

So – next time you need to setup unserialization, you just need to check the box, and enter the function name. You do not need to re-enter the function:

 

What’s Next

Our Work

Check out some recent work we’re proud of.

Our Blog

Read our latest ideas about tech, features, messaging, and more.

Get in Touch

Want to discuss a project? Hit us up, we’d love to chat!