admin管理员组

文章数量:1302417

i added a new field (property_second) to the admin area of the theme. and i want this field value to be the same as the post title. so if the post title changes, let it change here. how can I do it?

array(
            'key' => ERE_METABOX_PREFIX. 'property_second',
            'value' => $keyword,
            'type' => 'CHAR',
            'compare' => 'LIKE',
        ),

i added a new field (property_second) to the admin area of the theme. and i want this field value to be the same as the post title. so if the post title changes, let it change here. how can I do it?

array(
            'key' => ERE_METABOX_PREFIX. 'property_second',
            'value' => $keyword,
            'type' => 'CHAR',
            'compare' => 'LIKE',
        ),
Share Improve this question asked Mar 7, 2021 at 20:16 devo-zaradevo-zara 1 1
  • 1 Are you asking how to store the post title in a meta field, or how to update that meta field if/when the post title changes? – Pat J Commented Mar 8, 2021 at 1:37
Add a comment  | 

1 Answer 1

Reset to default 0

Hook into the post status transitions and copy the post title to your secondary field. See documentation:

https://codex.wordpress/Post_Status_Transitions#transition_post_status_Hook

本文标签: Move the post title to another field