<?php
/**
 * Template For Slider
 * @since 1.0
 * @package RoyalNews
 */

$royalnews_slider_data = get_query_var( 'royalnews_slider_data' );
$royalnews_post_data = get_query_var( 'royalnews_post_category' );
if( $royalnews_slider_data || $royalnews_post_data ):?>
    <div class="royalnews-main-slider-wrapper">
        <div class="container">
            <div class="royalnews-banner-slider-wrapper">
                <div class="royalnews-slider-left-wrapper">
                    <div class="royalnews-main-slider-initialize">
                        <?php foreach( $royalnews_slider_data as $rsd ): 
                            if( has_post_thumbnail( $rsd ) ){
                                $url = get_the_post_thumbnail_url( $rsd );
                            }else{
                                $url = get_template_directory_uri() . '/assets/images/placeholder.jpg';
                            }?>
                            <div class="royalnews-main-single-slide">
                                <div class="royanews-main-single-slider-img">
                                    <a href="<?php echo esc_url( get_the_permalink( $rsd ) ); ?>" class="royalnews-slider-link">
                                        <img src="<?php echo $url; ?>" alt="<?php the_title(); ?>">
                                    </a>
                                </div>
                                <div class="royalnews-slider-data">
                                    <?php royalnews_the_category( $rsd ); ?>
                                    <h2>
                                        <a href="<?php echo esc_url( get_the_permalink( $rsd ) ); ?>">                                
                                            <?php echo esc_html( get_the_title( $rsd ) ); ?>
                                        </a>
                                    </h2>
                                    <div class="royalnews-slider-meta">
                                        <?php royalnews_posted_by( get_the_id() );
                                        royalnews_the_date(); ?>
                                    </div>
                                </div>
                            </div>
                        <?php endforeach; ?>
                    </div>
                </div>
                <div class="royalnews-slider-right-wrapper">
                    <?php if( $royalnews_post_data ):?>
                    <div class="royalnews-banner-post">
                        <?php foreach( $royalnews_post_data as $rpd ):
                            if( has_post_thumbnail( $rpd ) ){
                                $url = get_the_post_thumbnail_url( $rpd );
                            }else{
                                $url = get_template_directory_uri() . '/assets/images/placeholder.jpg';
                            }?>
                            <div class="royalnews-main-single-slide">
                                <div class="royanews-main-single-slider-img">
                                    <a href="<?php echo esc_url( get_the_permalink( $rpd ) ); ?>" class="royalnews-slider-link">
                                        <img src="<?php echo $url; ?>" alt="<?php echo esc_html( get_the_title( $rpd ) ); ?>">
                                    </a>
                                </div>
                                <div class="royalnews-slider-data">
                                    <?php royalnews_the_category( $rpd ); ?>
                                    <h2>
                                        <a href="<?php echo esc_url( get_the_permalink( $rpd ) ); ?>">                                
                                            <?php echo esc_html( get_the_title( $rpd ) ); ?>
                                        </a>
                                    </h2>
                                    <div class="royalnews-slider-meta">
                                        <?php royalnews_posted_by( get_the_id() );
                                        royalnews_the_date(); ?>
                                    </div>
                                </div>
                            </div>
                       <?php endforeach; ?>
                    </div>
                </div>
            </div>
            <?php endif; ?>
        </div>
    </div>
<?php endif; ?>