最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

custom post types - WP Storing postmeta into revisions

programmeradmin1浏览0评论

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?

发布评论

评论列表(0)

  1. 暂无评论