HEX
Server: LiteSpeed
System: Linux premium321.web-hosting.com 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: paksjuts (1314)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: /home/paksjuts/apkhoop.com/wp-content/themes/hitmag/template-parts/related-posts.php
<?php

$categories = get_the_category();

if ( $categories ) { ?>

    <div class="hm-related-posts">
    
    <div class="wt-container">
        <h4 class="widget-title"><?php _e( 'Related Posts', 'hitmag' ); ?></h4>
    </div>

    <div class="hmrp-container">

        <?php

        $first_category = esc_attr( $categories[0]->term_id );
        $args = array(
            'cat'                   => array($first_category),
            'post__not_in'          => array($post->ID),
            'posts_per_page'        => 3,
            'ignore_sticky_posts'   => true
        );

        // Filter for Related Posts query arguments.
        $args = apply_filters( 'hitmag_related_posts_query_arguments', $args );

        $related_posts = new WP_Query($args);

        if( $related_posts->have_posts() ) :
            while ($related_posts->have_posts()) : $related_posts->the_post(); ?>

                <div class="hm-rel-post">
                    <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
                        <?php the_post_thumbnail( 'hitmag-grid' ); ?>
                    </a>
                    <h3 class="post-title">
                        <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
                            <?php the_title(); ?>
                        </a>
                    </h3>
                    <p class="hms-meta"><?php echo hitmag_posted_datetime() ?></p>
                </div>
            
            <?php
            endwhile;
        endif;

        wp_reset_postdata();

        ?>

    </div>
    </div>

    <?php

}