<div class="page-margin">
   <div class="row">
      <div class="col-md-8">
         <?php 
         if(Wo_IsLogged() === true) {
           echo Wo_LoadPage('story/publisher-box'); 
         }
         ?>
         <div class="hashtag-posts" id="posts_hashtag">
            <?php
            $stories = Wo_GetHashtagPosts($_GET['hash']);
            if (count($stories) <= 0) {
              echo Wo_LoadPage('hashtags/no-tag-found');
            } else {
              foreach ($stories as $wo['story']) {
                  echo Wo_LoadPage('story/content');
              }
            }
            ?>
         </div>
         <?php if (count($stories) > 4) { ?>
         <input type="hidden" value="<?php echo $_GET['hash'];?>" id="hashtagName">
         <div class="load-more pointer" id="load-more-posts" onclick="Wo_GetMoreHashTagsPosts();">
            <span class="btn btn-default"><i class="fa fa-chevron-circle-down progress-icon" data-icon="chevron-circle-down"></i> <?php echo $wo['lang']['load_more_posts'];?><span>
         </div>
         <?php } ?>
      </div>
      <?php 
      if(Wo_IsLogged() === true) {
        echo Wo_LoadPage('sidebar/content');
      } else {
        echo Wo_LoadPage('sidebar/guest');
      }
      ?>
   </div>
</div>
<?php if (count($stories) > 0) {  ?>
<script type="text/javascript">
$(function () {
  scrolled_hash = 0;
  // Stick the home side bar if the screen width is > than 900
  if(current_width > 900) {
    $(window).scroll(function () {
      var nearToBottom = 200;
      if($('#posts_hashtag').length > 0) {
          if ($(window).scrollTop() + $(window).height() > $(document).height() - nearToBottom) {
            if (scrolled_hash == 0) {
               scrolled_hash = 1;
               Wo_GetMoreHashTagsPosts();
            }
          }
      }
    });
  }
});
function Wo_GetMoreHashTagsPosts() {
    var more_posts = $('#load-more-posts');
    var after_post_id = $('.post:last').attr('data-post-id');
    var hashtagName = $('#hashtagName').val();
    Wo_progressIconLoader($('#load-more-posts'));
    $.post(Wo_Ajax_Requests_File() + '?f=get_more_hashtag_posts', {after_post_id: after_post_id,hashtagName:hashtagName}, function(data) {
        if (data.status == 200) {
            if (data.html.length == 0) {
                $('#posts_hashtag').append(data.html);
                more_posts.html('<span class="btn btn-default"><?php echo $wo["lang"]["no_more_posts"];?><span>');
            } else {
              $('#posts_hashtag').append(data.html);
            }
            Wo_progressIconLoader($('#load-more-posts'));
            scrolled_hash = 0;
        }
    });
}
</script>
<?php } ?>