<?php get_header(); ?>
    
  <?php get_sidebar(); ?>
      
      <div class="blog_main">
				<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
          
          <div class="post single-post" id="post-<?php the_ID(); ?>">
          
            <h2 class="blog_title"><?php the_title(); ?></h2>
          
            <div class="entry">
              <?php the_content(); ?>
            </div>
          
        </div>
        
        <?php endwhile; endif; ?> 
        
        
					 <?php
              $category = get_the_category(); //get first current category ID
              $this_post = $post->ID; // get ID of current post
              $posts = get_posts('numberposts=3&orderby=rand&category=' . $category[0]->cat_ID . '&exclude=' . $this_post);
							if (!empty($posts)) :
           ?>
           		<h3 style="margin-top: 20px;">Povezani blog postovi</h3>
           		<ul class="related_posts">
							 	<?php foreach($posts as $post) {  ?>
                <li><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title('')?></a></li>
         				<?php } ?>
              </ul>
					<?php wp_reset_postdata(); endif; ?>  
    </div>
    
    

<?php get_footer(); ?>
