<?php
// function that runs when shortcode is called
function show_allweblink_shortcode() {
	
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
 if($paged != 0)
 {
	 
 }
	$args = array(
     'post_type' => 'weblink',
     'posts_per_page' => 10,
     'paged' => $paged
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : 
global $post;
$loop->the_post();
     // CPT content
	 $weblink_url = get_post_meta( $post->ID, 'weblink_url', true ); 
	 
	$weblink_desc = get_post_meta( $post->ID, 'weblink_desc', true );
	 ?>
	 <div itemscope="" itemtype="http://schema.org/Article">

			<div class="story_data">
				  			<div class="votebox votebox-new">
								<div class="title" id="title-1977">
									<span itemprop="name">
										<h2 dir="ltr">
											<a href="<?php echo the_permalink(); ?>"><?php echo the_title(); ?></a>
																</h2>
									</span>	
			<span class="subtext">
				<span id="ls_avatar-1977"><img  style= "display : inline;" itemprop="image" src="<?php echo plugin_dir_url( __FILE__ ) . 'img/avtar.png'; ?>" width="32px" height="32px"></span>				<span itemprop="author" itemscope="" itemtype="http://schema.org/Person">
				<span itemprop="name">
				<?php
				$a_id=$post->post_author;
				the_author_meta( 'user_nicename', $a_id ); ?>  
				</span></span>
				<i class="fa fa-clock-o"></i>
				<span itemprop="datePublished"><?php the_date(); ?></span>
				
				<i class="fa fa-folder"></i> 
				<?php $terms = wp_get_post_terms( $post->ID, array( 'category_weblink') ); ?>
						<?php
						$index = 0;
						foreach ( $terms as $term ) : 
						if($index) echo " , ";
						?>
						<?php echo $term->name; $index = $index + 1 ;?>
						<?php endforeach; ?>
                    				
															<i class="fa fa-tag"></i>
																						<?php $terms = wp_get_post_terms( $post->ID, array( 'tag_weblink') ); ?>
						<?php
						$index = 0;
						foreach ( $terms as $term ) : 
						if($index) echo " , ";
						echo $term->name; $index = $index + 1 ;?>
						<?php endforeach; ?>						
									<i class="fa fa-globe"></i>
					<a href="<?php echo $weblink_url; ?>" rel="nofollow"><?php echo $weblink_url; ?></a>
			</span>
		</div><!-- /.title -->
	</div> <!-- /.story_data -->
	<span itemprop="articleBody">
	<div class="storycontent">
									
			<div class="news-body-text" id="ls_contents-1977" dir="ltr">
															
						<?php echo $weblink_desc; ?>							 
																																																																
				
				<div class="clearboth"></div> 
                </div>
						</div><!-- /.storycontent -->
	</span>
	</div>
	<hr>
	<?php
endwhile;
?>
<div class="pagination">
     <?php
     $big = 999999999;
     echo paginate_links( array(
          'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
          'format' => '?paged=%#%',
          'current' => max( 1, get_query_var('paged') ),
          'total' => $loop->max_num_pages,
          'prev_text' => '&laquo;',
          'next_text' => '&raquo;'
     ) );
?>
</div>
<?php wp_reset_postdata(); 

} 
// register shortcode
add_shortcode('show-all-weblink', 'show_allweblink_shortcode');