Server IP : 89.26.249.46  /  Your IP : 216.73.216.42
Web Server : Apache
System : Linux a.cp.cloudlink.pt 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User : eticalga ( 1129)
PHP Version : 8.3.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home/eticalga/www/files/themes/kobuxeticalgarve/partials/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/eticalga/www/files/themes/kobuxeticalgarve/partials/related-articles.php
<?php

/**
 * Partial: Related articles
 *
 * @package kobuxeticalgarve
 */

$related_articles_option = get_field('related_articles_option');

if ($related_articles_option !== 'none') {
    if ($related_articles_option == 'manual') {
        $related_articles = get_field('related_articles');
        $has_articles = !empty($related_articles);
    } else {
        $tax_query = array();

        $category_list = wp_get_post_terms(
            get_the_ID(),
            'category',
            array(
                'fields' => 'ids'
            )
        );

        if ($category_list) {
            $tax_query[] = array(
                array(
                    'taxonomy' => 'category',
                    'terms'    => $category_list,
                )
            );
        }

        $post_tag_list = wp_get_post_terms(
            get_the_ID(),
            'post_tag',
            array(
                'fields' => 'ids'
            )
        );

        if ($post_tag_list) {
            $tax_query[] = array(
                array(
                    'taxonomy' => 'post_tag',
                    'terms'    => $post_tag_list,
                )
            );
        }

        if (count($tax_query) > 0) {
            $tax_query['relation'] = 'OR';
        }

        $args = array(
            'post_type'         => array('post'),
            'post_status'       => array('publish'),
            'posts_per_page'    => 10,
            'post__not_in'      => array(get_the_ID()),
            'tax_query'            => $tax_query,
        );

        $kobu_query = new WP_Query($args);
        $has_articles = $kobu_query->have_posts();

        if ($kobu_query->have_posts()) {
            $related_articles = $kobu_query->posts;
        } else {
            $related_articles = array();
        }
    }

    if ($has_articles) { ?>
        <div class="related-articles-wrapper alignfull">
            <h2><?php _e('Related articles', 'kobu'); ?></h2>
            <ul class="related-articles posts-slider">
                <?php foreach ($related_articles as $post) {
                    setup_postdata($post);
                    get_template_part('content', 'list-post');
                } ?>
            </ul>
            <?php wp_reset_postdata(); ?>
        </div>
<?php }
}