function shortcode_portfolio($atts, $content = null)
{
    global $postParentPageID, $portfolio_page, $tpl_body_id, $no_of_page_columns;
    extract(shortcode_atts(array('cats' => '', 'per_page' => '10', 'orderby' => 'date', 'order' => 'desc', 'offset' => '0', 'title' => 'true', 'description' => 'true', 'layout' => '2columns', 'pagination' => 'true', 'crop' => 'center'), $atts));
    $crop = $crop ? $crop : 'center';
    $crop = strtolower($crop);
    $crop = trim($crop);
    //croping image location
    if ($crop == "top") {
        $str_crop = "Align top";
    } elseif ($crop == "top right") {
        $str_crop = "Align top right";
    } elseif ($crop == "top left") {
        $str_crop = "Align top left";
    } elseif ($crop == "bottom") {
        $str_crop = "Align bottom";
    } elseif ($crop == "bottom right") {
        $str_crop = "Align bottom right";
    } elseif ($crop == "bottom left") {
        $str_crop = "Align bottom left";
    } elseif ($crop == "left") {
        $str_crop = "Align left";
    } elseif ($crop == "right") {
        $str_crop = "Align right";
    }
    //////////// end crop location ////////
    global $wp_query, $data;
    $kingsize_page_porfolio_category_arr = explode(",", $cats);
    // Pagination
    if (get_query_var('paged')) {
        $paged = get_query_var('paged');
    } elseif (get_query_var('page')) {
        $paged = get_query_var('page');
    } else {
        $paged = 1;
    }
    // Post Query
    #### creating arguments #######
    if ($cats != '') {
        $args_portfolio = array("tax_query" => array(array("taxonomy" => "portfolio-category", "field" => "id", "terms" => $kingsize_page_porfolio_category_arr)), 'post_type' => array('portfolio'), 'order' => $order, 'orderby' => $orderby, 'posts_per_page' => $per_page, 'paged' => $paged);
    } else {
        $args_portfolio = array('post_type' => array('portfolio'), 'order' => $order, 'orderby' => $orderby, 'posts_per_page' => $per_page, 'paged' => $paged);
    }
    $no_of_page_columns = $layout;
    ob_start();
    ?>
		<!-- Gallery with PrettyPhoto plugin -->
		<div id="gallery_prettyphoto" class="portfolio">
			 <ul class="gallery_<?php 
    echo $no_of_page_columns;
    ?>
">
			 <?php 
    $count = 1;
    $temp = $wp_query;
    $wp_query = null;
    $wp_query = new WP_Query();
    $wp_query->query($args_portfolio);
    if ($wp_query->max_num_pages > 0) {
        $portfolio_page = 'portfolio';
        $tpl_body_id = "prettyphoto";
        while ($wp_query->have_posts()) {
            $wp_query->the_post();
            $postid = $wp_query->post->ID;
            $the_post = get_post($postid, ARRAY_A);
            //if CUSTOM LINK has been set from write up panel for the permalink
            if (get_post_meta($postid, 'portfolios_read_more_link', true) != '') {
                $permalink = get_post_meta($postid, 'portfolios_read_more_link', true);
            } else {
                $permalink = get_permalink($postid);
            }
            ?>
				<li>            
					<?php 
            if ($title == "true") {
                ?>
						<h3 class="post_title"><a href="<?php 
                echo $permalink;
                ?>
"><?php 
                echo $the_post["post_title"];
                ?>
</a></h3>
					<?php 
            } else {
                ?>
<!-- No Titles --><?php 
            }
            ?>
					
					<!-- Portfolio post-thumb gallery -->
						<?php 
            kingsize_thumb_box($postid, $str_crop);
            ?>
					<!-- END Portfolio post-thumb gallery -->

					 <!--BEGIN excerpt content -->
					 <?php 
            if ($description == 'true') {
                ?>
						<p><?php 
                echo substr($wp_query->post->post_excerpt, 0, 240);
                ?>
</p>
					<?php 
            }
            ?>
	
					 <!--END excerpt content -->

					<?php 
            //checking read more text has been set from the write up panel
            if (get_post_meta($postid, 'portfolios_read_more_disable', true) != 1) {
                if (get_post_meta($postid, 'portfolios_read_more_text', true) != '') {
                    echo '<a href="' . $permalink . '" class="more-link">' . get_post_meta($postid, 'portfolios_read_more_text', true) . '</a>';
                } else {
                    echo '<a href="' . $permalink . '" class="more-link">' . __("Read More", "kslang") . '</a>';
                }
            }
            ?>
				</li>	
				<?php 
            $count++;
        }
        ?>
										
			<?php 
    } else {
        echo '<li>No portfolio yet.</li>';
    }
    ?>
	
		</ul>
	  </div>	
	<!-- End Gallery with PrettyPhoto plugin -->


	<?php 
    if ($pagination == "true") {
        kingsize_pagination($wp_query->max_num_pages);
    }
    $output_string = ob_get_contents();
    ob_end_clean();
    wp_reset_postdata();
    $wp_query = null;
    $wp_query = $temp;
    return $output_string;
}
                        ?>
<h3 class="post_title"><a href="<?php 
                        echo $permalink;
                        ?>
"><?php 
                        echo $the_post["post_title"];
                        ?>
</a></h3><?php 
                    } else {
                        ?>
<!-- No Titles --><?php 
                    }
                    ?>
									<!-- Portfolio post-thumb gallery -->
										<?php 
                    kingsize_thumb_box($post->ID);
                    ?>
									<!-- END Portfolio post-thumb gallery -->
									 <!--BEGIN excerpt content -->
	                                    <p><?php 
                    echo substr($post->post_excerpt, 0, 240);
                    ?>
</p>
									 <!--END excerpt content -->

									<?php 
                    //checking read more text has been set from the write up panel
                    if (get_post_meta($post->ID, 'portfolios_read_more_disable', true) != 1) {
                        if (get_post_meta($post->ID, 'portfolios_read_more_text', true) != '') {
                            echo '<a href="' . $permalink . '" class="more-link">' . get_post_meta($post->ID, 'portfolios_read_more_text', true) . '</a>';
                        } else {
            $permalink = get_post_meta($post["ID"], 'portfolios_read_more_link', true);
        } else {
            $permalink = get_permalink($post["ID"]);
        }
        ?>
			<li>            
				<h3 class="post_title"><a href="<?php 
        echo $permalink;
        ?>
"><?php 
        echo $the_post["post_title"];
        ?>
</a></h3>  
				<!-- Portfolio post-thumb gallery -->
					<?php 
        kingsize_thumb_box($post["ID"]);
        ?>
				<!-- END Portfolio post-thumb gallery -->
				 <!--BEGIN excerpt content -->
					<p><?php 
        echo substr($post["post_excerpt"], 0, 240);
        ?>
</p>
				 <!--END excerpt content -->

				<?php 
        //checking read more text has been set from the write up panel
        if (get_post_meta($post["ID"], 'portfolios_read_more_disable', true) != 1) {
            if (get_post_meta($post["ID"], 'portfolios_read_more_text', true) != '') {
                echo '<a href="' . $permalink . '" class="more-link">' . get_post_meta($post["ID"], 'portfolios_read_more_text', true) . '</a>';
            } else {