<?php
/**
 * Template For Header Top stories
 * @since 1.0
 * @package RoyalNews
 */
$stories_post = royalnews_get_posts_by_type( royalnews_value( 'stories-type' ), royalnews_value( 'stories-category' ), 6 );
if( !empty($stories_post) ){ ?>
    <div class="royalnews-stories-main-wrapper">
        <div class="container">
            <div class="royalnews-exclusive-posts">
                <div class="royalnews-top-stories">        
                    <?php $title = royalnews_value( 'stories-title-text' );
                    if( '' != $title ){ ?>
                        <div class="royalnews-news-spinner">
                            <span></span>
                        </div>
                        <h3 class="royalnews-stoories-title"><?php echo esc_html( $title ); ?></h3>
                    <?php } ?>
                </div>
                <div class="royalnews-main-stories">
                    <div class="royalnews-stories-wrap">
                        <?php foreach( $stories_post as $sp ){ 
                            if( has_post_thumbnail( $sp ) ){
                                $img = get_the_post_thumbnail_url( $sp, 'thumbnail' );
                            }else{
                                $img = get_template_directory_uri() . '/assets/images/placeholder.jpg';
                            } ?>
                            <div class="royalnews-stories-inner">     
                                <div class="royalnews-stories-image">                        
                                    <a href="<?php echo esc_url( get_the_permalink( $sp ) ); ?>">                        
                                        <img src="<?php echo esc_url( $img ); ?>">
                                    </a>
                                </div>
                                <div class="royalnews-stories-meta">
                                    <div class="royalnews-stories-date">
                                        <?php royalnews_the_date( $sp ); ?>
                                    </div>
                                    <div class="royalnews-stories-title">
                                       <a href="<?php echo esc_url( get_the_permalink( $sp ) ); ?>">
                                            <p><?php echo get_the_title( $sp ); ?></p>   
                                       </a> 
                                    </div>
                                </div>
                            </div>
                        <?php } ?>
                    </div>
                </div>
            </div>
        </div>
    </div>
<?php }