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
版权声明:本文标题:custom post types - WP Storing postmeta into revisions 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741982272a2408468.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论