File: //var/www/linde-ai/wp-content/themes/linde/pages/articles.php
<?php
/*
 * Template Name: Articles
 */
$context = Timber::context();
global $paged;
if (!isset($paged) || !$paged){
    $paged = 1;
}
/*
 * Query arguments to fetch posts while filtering based on the custom ACF field 'post_visibility'.
 *
 * Filtering logic:
 * 1. Posts where 'post_visibility' **does not exist** (i.e., no visibility option selected) are included.
 *    - This ensures that posts without a manually set visibility option are shown.
 *    - The default option when 'post_visibility' is not explicitly selected is "website"
 * 2. Posts where 'post_visibility' is explicitly set to 'lva-platform' are excluded.
 * 3. Posts with any other value ("website" or "everywhere") are included.
 *
 * The 'relation' => 'OR' ensures that either of these conditions can be true:
 * - If the field does not exist → Show the post.
 * - If the field exists and IS NOT set to 'lva-platform' → Show the post.
 * - If the field exists and is set to 'lva-platform' → Exclude the post.
 */
$args = array(
    'numberposts' => 6,
    'paged' => $paged,
    'orderby' => 'date',
    'order'   => 'DESC',
    'meta_query' => array(
        'relation' => 'OR',
        array(
            'key' => 'post_visibility',
            'compare' => 'NOT EXISTS' 
        ),
        array(
            'key' => 'post_visibility',
            'value' => 'lva-platform',
            'compare' => '!='
        )
    )
);
$news = new Timber\PostQuery($args);
$context['posts'] = $news;
$context['pagination'] = $context['posts'];
Timber::render( array( 'pages/articles.twig', 'page.twig' ), $context );