<?php
/*
Template Name:My Product Oli Page
*/

?>   

<?php get_header(); ?>
        <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post-body pages">        
<?php get_sidebar('left'); ?> 
<div class="posts-wrap three_col"> 
   <? //print_r($post)?>
<div class="post" id="page">
        
        <h2 class="page-title">
            
            <?php the_title(); ?>
        </h2>

            <div class="entry-content" id="page-content">
            
                <?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>

                <?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
            </div><!-- end #page-content -->

    </div><!-- end #page -->
    <div class="cat_static_blocks_product" style="margin-top: -5px;">  
           <?php  
           $category_id = get_post_meta($post->ID, 'category_id', true); 
           $args = array(
                        'type'                     => 'post',
                        'child_of'                 => $category_id,
                        'parent'                   => '',
                        'orderby'                  => 'slug',
                        'order'                    => 'ASC',
                        'hide_empty'               => 1,
                        'hierarchical'             => 1,
                        'exclude'                  => '',
                        'include'                  => '',
                        'number'                   => '',
                        'taxonomy'                 => 'category',
                        'pad_counts'               => false );
           $cats = get_categories($args); 
             // print('<pre>');
             //  print_r($cats); 
               
?>
                 
                     <?php $cat_id_page = $category_id; ?> 
                    <?php $args = array( 'numberposts' => '-1','cat'=>"$cat_id_page",'order'=>'asc','orderby'=>'ID' );
                      $pageposts = get_posts( $args );
                      $i_row = 1;?>
                      <?php foreach ($pageposts as $post): ?> 
                        
                        <div class="cat_item ">
                              <table>
                                <tr>
                                    <td width="180" valign="top" bgcolor="#ffffff" align="center" style="padding: 5px"> 
					<?php $url_product = get_permalink( $post->ID );// get_post_meta($post->ID, 'url_product', true); ?> 
                                     	<a href="<?php echo $url_product; ?>" target="_blank"> 
					<img src="<? echo get_Image_url($post->ID,'m','thumbnail');?>" alt="" height="325" width="180">
					</a>
				    </td>
                                    <td valign="top"  style="padding: 5px">
                                    <h3><a href="<?php echo $url_product; ?>" target="_blank"><?php echo $post->post_title;?></a></h3>
                                    <?php echo apply_filters('the_content', $post->post_content); ?>
                                    </td>
                                </tr>
                              </table>
                        </div>
                        <?php //if($i_row==2){echo '<br class="clear"> '; $i_row=0;}?>
                        <?php $i_row += 1; ?>
                        <?php endforeach; ?>
                        <br class="clear"> 

    
       
      </div>                 
    
            <?php endwhile; endif; ?>
            
    <?php edit_post_link( __('Edit this page', 'blank'), '<p>', '</p>'); ?>
 </div><!-- end .posts-wrap -->
    
<?php get_sidebar('right'); ?>
</div>
<?php get_footer('all'); ?>