Hi @marcorroma
Is it possible to import a “sticky post” from an xml file? So that it is automatically set as “sticky post”.
You could use custom code and our pmxi_saved_post hook to do that: https://www.wpallimport.com/documentation/advanced/action-reference/#pmxi_saved_post.
As an example, if you have an import element called {sticky[1]} with a value of “1” for sticky posts and a value of “0”, or anything else, for non-sticky posts, this snippet would work:
function my_maybe_stick_imported_post( $id, $xml_data, $update ) {
$xml_record = json_decode( json_encode( (array) $xml_data ), 1 );
if ( array_key_exists( 'sticky', $xml_record ) ) {
if ( $xml_record['sticky'] == '1' ) {
stick_post( $id );
}
}
}
add_action( 'pmxi_saved_post', 'my_maybe_stick_imported_post', 10, 3 );