现代部落已经发表了几篇文章来解决像你这样的问题。
请看一下他们的文章“Tips for Working With WordPress Actions and Filters“看看你能不能找到do_action()
或apply_filters()
在后期保存或发布事件之后发生的语句。
我相信你可能想要add_action(\'tribe_events_update_meta\',\'wpse_your_function\', 10,3)
, 在中找到/src/Tribe/API.php
. 以下是他们对此的文档:
/**
* Allow hooking in after all event meta has been saved.
*
* @param int $event_id The event ID we are modifying meta for.
* @param array $data The meta fields we want saved.
* @param WP_Post $event The event itself.
*
* @since 4.6
*/
do_action( \'tribe_events_update_meta\', $event_id, $data, $event );
你应该去看看。
如果成功,您的代码将是Pat J建议的修改版本:
add_action( \'tribe_events_update_meta\', \'wpse348671_updated_meta\', 10, 3 );
function wpse348671_updated_meta( $event_id, $data, $event ) {
// Update/create your 2nd post here.
//The event start date should be stored in $data[\'EventStartDate\'].
// this should work too.
$start = get_post_meta( $event_id, \'_EventStartDate\', true )
}