ID, '_archive_page', true ); ?>
Choisissez la cible de cette page
ID, 'archive_page-nonce') ; } //sauvegarde de la metabox add_action( 'save_post', 'my_save_post' ); function my_save_post( $post_ID ){ // on retourne rien du tout s'il s'agit d'une sauvegarde automatique if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return $post_ID; if ( isset( $_POST[ 'archive_page' ] ) ) { check_admin_referer( 'archive_page-save_' . $_POST[ 'post_ID' ], 'archive_page-nonce' ); if( isset( $_POST[ 'archive_page' ] ) ) { $target = $_POST[ 'archive_page' ]; global $wpdb; $suppr = $wpdb->get_results( $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_archive_page' AND meta_value = '%s'"), $target ); foreach( $suppr as $s ) delete_post_meta( $s->post_id, '_archive_page' ); update_post_meta( $_POST[ 'post_ID' ], '_archive_page', $_POST[ 'archive_page' ] ); } } } //présentation de l'archive function presentation_archive() { $post_type_obj = get_queried_object(); $target = $post_type_obj->name; $presentation = new WP_Query( array( 'post_type' => 'page', 'meta_query' => array( array( 'key' => '_archive_page', 'value' => $target, 'compare' => '=' ) ) ) ); if( $presentation->have_posts() ) : $presentation->the_post(); the_title( '