- 
	
	
		
			
			
				عضو انجمن
			
			
			
			
			
			
				
			
			 
			
				
				
				
				
				
					    
				
			
		 
		
			
				
				
				
					
 نمایش پست های رندوم بدون پلاگین
				
				
						
							
							
						
						
							
						
				
					
						
							کد زیر را در فایل functions.php قرار بدید :
	کد:
	function wpb_rand_posts() { 
$args = array(
	'post_type' => 'post',
	'orderby'	=> 'rand',
	'posts_per_page' => 5, 
	);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) {
$string .= '<ul>';
	while ( $the_query->have_posts() ) {
		$the_query->the_post();
		$string .= '<li><a href="'. get_permalink() .'">'. get_the_title() .'</a></li>';
	}
	$string .= '</ul>';
	/* Restore original Post Data */
	wp_reset_postdata();
} else {
$string .= 'no posts found';
}
return $string; 
} 
add_shortcode('wpb-random-posts','wpb_rand_posts'); add_filter('widget_text', 'do_shortcode'); 
 هرجا که میخواهید پست ها نمایش داده شود از کد کوتاه زیر استفاده کنید :
						
					 
					
				 
			 
			
			
				
				
				
					 
				
				
					طراحی قالب وب سایت
PSD/HTML/Wordpress
طراحی بنر گیف، لوگو، پوستر و ...
				
				
			 
			
			
		 
	 
		
	
 
- 
    
    
    
    
    
        
            تعداد تشکر ها از JahanSoft به دلیل پست مفید 
        
    
    
         
     
 
		
		- 
		
			
						
						
							May 4th, 2017 22:34
						
					
					
						
							 # ADS