Domanda

Vorrei inserire i dati nella tabella WP_POSTS con il post_id inserito nel "GUID" per un record che non esiste già. Di seguito è riportato il più vicino che ho ottenuto ma questo non funziona ($ postarr ['id'] è uguale a 0).

function filter_handler( $data , $postarr )
{
if($data['post_type']=='ai1ec_event'){
    $my_post_id = $postarr['ID'];
    $data['guid'] = get_option('siteurl') .'/?post_type=ai1ec_event&p='.$my_post_id.'&instance_id=';
}

return $data;
}

add_filter( 'wp_insert_post_data' , 'filter_handler' , '99', 2 );

$mypost = array(
  'post_author'     => 1,
 'post_content'     => 'Test', 
 'post_status'      => 'publish',
 'post_title'       => $_GET['assignment_name'],
 'post_type'        => 'ai1ec_event',
 'guid'     => ''
); 

$postid = wp_insert_post($mypost);

Nessuna soluzione corretta

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a wordpress.stackexchange
scroll top