Compare commits

...

2 Commits

Author SHA1 Message Date
0a3721a82a REFACTOR Removing duplicate get_header
All checks were successful
continuous-integration/drone/push Build is passing
2025-05-27 13:59:58 +02:00
90ed4c674b FIX Making offline post unacessible to public 2025-05-27 13:59:23 +02:00
2 changed files with 10 additions and 3 deletions

View File

@ -50,7 +50,7 @@ function custom_post_status()
{ {
register_post_status('offline', array( register_post_status('offline', array(
'label' => __('Hors ligne', 'metiers-patrimoine-theme'), 'label' => __('Hors ligne', 'metiers-patrimoine-theme'),
'public' => true, 'public' => false,
'exclude_from_search' => false, 'exclude_from_search' => false,
'show_in_admin_all_list' => true, 'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true, 'show_in_admin_status_list' => true,
@ -59,7 +59,15 @@ function custom_post_status()
} }
add_action('init', 'custom_post_status'); add_action('init', 'custom_post_status');
// Permettre aux utilisateurs connectés de voir les posts 'offline'
function allow_logged_in_users_to_view_offline_posts($query)
{
if (!is_admin() && $query->is_main_query() && is_user_logged_in()) {
$query->set('post_status', array('publish', 'offline'));
}
return $query;
}
add_filter('pre_get_posts', 'allow_logged_in_users_to_view_offline_posts');
function add_to_post_status_dropdown() function add_to_post_status_dropdown()
{ {

View File

@ -3,7 +3,6 @@ get_header();
?> ?>
<?php <?php
get_header();
$pageIcon = get_field('page_icon', get_queried_object_id()) ?? null; $pageIcon = get_field('page_icon', get_queried_object_id()) ?? null;
?> ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?>