REFACTOR Moving the post type declaration to the mu-plugin
This commit is contained in:
parent
44a6c0ef03
commit
a9467c2ce2
|
|
@ -3,31 +3,14 @@
|
|||
// THE POST TYPE IS DECLARED IN THE MU-PLUGINS/CARHOP-POST-TYPES.PHP FILE
|
||||
|
||||
|
||||
function handle_posts_analyses_etudes_numerotation_remapping()
|
||||
{
|
||||
// Ne s'exécuter que dans l'admin pour éviter de surcharger le frontend
|
||||
if (!is_admin()) {
|
||||
return;
|
||||
}
|
||||
// function handle_posts_analyses_etudes_numerotation_remapping()
|
||||
// {
|
||||
// // Ne s'exécuter que dans l'admin pour éviter de surcharger le frontend
|
||||
// if (!is_admin()) {
|
||||
// return;
|
||||
// }
|
||||
// handle_posts_numerotation_remapping('analyses-etudes');
|
||||
// }
|
||||
|
||||
$args = array(
|
||||
'post_type' => 'analyses-etudes',
|
||||
'posts_per_page' => -1,
|
||||
'orderby' => 'date',
|
||||
'order' => 'ASC',
|
||||
);
|
||||
|
||||
$query = new WP_Query($args);
|
||||
|
||||
if ($query->have_posts()) {
|
||||
while ($query->have_posts()) {
|
||||
$query->the_post();
|
||||
$current_numerotation = $query->current_post + 1;
|
||||
update_post_meta(get_the_ID(), 'post_numerotation', $current_numerotation);
|
||||
}
|
||||
wp_reset_postdata();
|
||||
}
|
||||
}
|
||||
|
||||
add_action('save_post', 'handle_posts_analyses_etudes_numerotation_remapping');
|
||||
add_action('delete_post', 'handle_posts_analyses_etudes_numerotation_remapping');
|
||||
// add_action('save_post', 'handle_posts_analyses_etudes_numerotation_remapping');
|
||||
// add_action('delete_post', 'handle_posts_analyses_etudes_numerotation_remapping');
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user