admin管理员组

文章数量:1315221

I've made it possible to store some standard meta fields into a custom post type revision with the help if this great article: /

But my custom post type posts have different meta fields. So how can I send all fields from a specific post to the revision fields filter:

add_filter( '_wp_post_revision_fields','my_meta_fields', 10, 1 );   
function my_meta_fields( $fields ) {
  $fieldsAdd = object_fields();
   foreach($fieldsAdd as $fieldname => $fieldTitle){ 
     $fields[$fieldname] = $fieldTitle; 
   }
 return $fields;
}

function object_fields(){
    global $objectStandardFields;
    foreach ($objectStandardFields as $objectStandardField) {
        $fields[$objectStandardField] = $objectStandardField;
    }
    return $fields;
}

Is there a way to get the current post data inside the filter so that I can get all field names from it?

And an other problem with this is the revision preview. Some of my meta fields contain arrays. But the revision preview seems to have problems showing arrays. For every meta field with an array I get the following error:

Warning: trim() expects parameter 1 to be string, array given in /wp-includes/formatting.php on line 5276

Is there a way to help wordpress to convert arrays to show them in revisions?

本文标签: custom post typesWP Storing postmeta into revisions