<?php
/**
 * Template Name: عرض المقالات
 */
?>
	<?php get_header(); ?>

			<?php do_action( 'bp_before_blog_page' ) ?>





<!-- start of main body -->
<div class="w960px">



<!-- start of colums erea -->
  <div id="columns">
			<h2 class="post-title page-title"><?php the_title(); ?></h2>

            

<?php
// set the $paged variable
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
// query the posts of your custom post types
query_posts( array(
		'post_type' => array(
					'article',
				),
        'showposts' => '12',				
				'paged' => $paged ) // for paging links to work
			);

if (have_posts()) :
	while (have_posts()) : the_post(); ?> 
    
    
<div class="post">
  <div class="post-img"> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
   <?php
$attachments = get_children(array
('post_parent' => get_the_ID(),
 'post_type' => 'attachment',
 'post_mime_type' => 'image',
 'orderby' => 'menu_order'));
if ( has_post_thumbnail() ) {
the_post_thumbnail( array(150,150) );
} elseif ($attachments) {
    if ( ! is_array($attachments) ) continue;
    $count = count($attachments);
    $first_attachment = array_shift($attachments);
    echo wp_get_attachment_image($first_attachment->ID);
} else {
	$table = "wp_posts";
	if($table_prefix !='' || $table_prefix != ''){
		$table = $table_prefix."posts ";
	}
	$row = mysql_fetch_assoc(mysql_query("SELECT * FROM " . $table . " WHERE id =".get_the_ID()));
	$row = explode('||',$row['post_excerpt']);
	if(preg_match('/(png|jpg|jpeg|gif|bmp)$/iUs',$row[1]) == true){
		echo '<img class="thumb" src="'.$row[1].'" alt=" " height="150" width="150" />';
 	}else{
	    echo '<img class="thumb" src="'. get_template_directory_uri().'/theme-files/img/no-img/post-thumb.png" height="150" width="150" />';
	}
}
?>
    </a> </div>
  <div class="post-right">
    <h2 class="post-title"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
      <?php the_title(); ?>
      </a></h2>
    <em class="meta">
    <?php _e( 'بتاريخ : ', 'MCL' ) ?>
    <?php the_time(get_option('date_format')); ?>
    <?php _e( ',فى قسم : ', 'MCL' ) ?>
    <?php the_category(', '); ?>
    <?php _e( ', التعليقات : ', 'MCL' ) ?>
    <?php comments_popup_link( __( 'لا توجد تعليقات', 'MCL' ), __( 'تعليق واحد', 'MCL' ), __( '% تعليق', 'MCL' ) ); ?>
    </em>
    <p class="post-content"><?php echo substr(strip_tags(get_the_content()),0,500); ?></p>
    <p class="read-more"><a href="<?php the_permalink() ?>" title="الموضوع بالكامل">
      <?php _e('تابع الموضوع', 'MCL'); ?>
      </a></p>
  </div>
</div>
<!--.post-->

<?php do_action( 'bp_after_blog_post' ) ?>
<?php endwhile;
		endif; ?>
<div class="pagination"><?php pagination('«', '»'); ?></div>


</div></div>




			<?php do_action( 'bp_after_blog_page' ) ?>



	<?php get_footer(); ?>