function kingsize_slider_custom_columns($column)
{
    global $post;
    switch ($column) {
        case "slider_categories":
            echo get_the_term_list($post->ID, __('slider-category'), '', ', ', '');
            break;
        case "slider_image":
            if (has_post_thumbnail()) {
                $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'single-post-thumbnail');
                $url_img = wm_image_resize('50', '50', $image[0]);
                echo '<img src="' . $url_img . '" width="' . $image[width] . '" height="' . $image[height] . '" alt="" />';
            }
            break;
    }
}
function kingsize_portfolio_custom_columns($column)
{
    global $post;
    switch ($column) {
        case "portfolio_categories":
            echo get_the_term_list($post->ID, __('portfolio-category'), '', ', ', '');
            break;
        case "portfolio_image":
            $image_portfolio = get_post_meta($post->ID, 'upload_image', true);
            $video_thumb_image = get_post_meta($post->ID, 'upload_image_thumb', true);
            if ($image_portfolio != '') {
                $overview_image = $image_portfolio;
            } elseif ($video_thumb_image != '') {
                $overview_image = $video_thumb_image;
            } else {
                $overview_image = kingsize_get_the_post_thumbnail_url($post->ID);
            }
            if ($overview_image != '') {
                $url_post_img = wm_image_resize('50', '50', $overview_image);
                echo '<img src="' . $url_post_img . '" width="50" height="50" alt="" />';
            }
            break;
    }
}
            $post_featured_img_height = get_post_meta($post->ID, 'kingsize_post_featured_img_height', true);
        } else {
            $post_featured_img_height = 180;
        }
        //Sidebar enabled
        if ($data['wm_sidebar_enabled'] == "1" && get_post_meta($postParentPageID, 'page_sidebar_hide', true) == "") {
            $post_featured_img_width = 460;
        } else {
            $post_featured_img_width = 680;
        }
        //showing full width
        if (has_post_thumbnail()) {
            // POST has thumbnail
            $org_img_url = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
            $attachment_id = get_post_thumbnail_id($post->ID);
            $url_post_img = wm_image_resize($post_featured_img_width, $post_featured_img_height, wp_get_attachment_url($attachment_id));
            if ($show_image_lightbox == 'enable') {
                echo '<a href="' . $org_img_url . '" class="image lightbox_blog" title="' . get_the_title() . '" rel="gallery"><img src="' . $url_post_img . '" title="' . get_the_title() . '" class="blog_thumbnail"/></a>';
            } else {
                echo '<a href="' . get_permalink($post->ID) . '" class="image" title="' . get_the_title() . '"><img src="' . $url_post_img . '" title="' . get_the_title() . '" class="blog_thumbnail"/></a>';
            }
        }
        ?>
								<!-- END Post thubmnail -->

								<!-- POST Content -->
								<?php 
        ///Enable the gallery with next previous of images
        if ($data['wm_enable_rtf_excerpts'] == '0') {
            echo get_the_content_with_formatting($data['wm_read_more_text']);
        } elseif ($data['wm_blog_img_gallery_nxt_prev'] == "1") {
">							
							<?php 
            //getting the page Gallery attachments images
            $args = array('post_type' => 'attachment', 'post_parent' => $post->ID, 'orderby' => "menu_order ID", 'order' => ASC);
            $attachments = get_children($args);
            $url_post_img = "";
            if ($attachments) {
                foreach ($attachments as $attachment) {
                    if ($no_of_page_columns == "2columns") {
                        $url_post_img = wm_image_resize('330', '220', wp_get_attachment_url($attachment->ID));
                    } elseif ($no_of_page_columns == "3columns") {
                        $url_post_img = wm_image_resize('220', '140', wp_get_attachment_url($attachment->ID));
                    } elseif ($no_of_page_columns == "4columns") {
                        $url_post_img = wm_image_resize('160', '110', wp_get_attachment_url($attachment->ID));
                    } elseif ($no_of_page_columns == "grid") {
                        $url_post_img = wm_image_resize('112', '112', wp_get_attachment_url($attachment->ID));
                    }
                    if (!empty($attachment->post_content)) {
                        $post_title = "<p>" . strip_tags($attachment->post_content) . "</p>";
                    } else {
                        $post_title = $attachment->post_title;
                    }
                    $post_title = $attachment->post_title . "<p>" . strip_tags($attachment->post_content) . "</p>";
                    if (get_post_meta($attachment->ID, '_wp_attachment_image_alt', true) == "") {
                        $post_alt = $attachment->post_title;
                    } else {
                        $post_alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true);
                    }
                    ?>
									<li><a href="<?php 
                    echo wp_get_attachment_url($attachment->ID);
 function getAttachedImages($_max = 5, $order = 'latest', $linktype = 'page', $linkclass = '', $linkrel = '', $thumbsize = 'thumbnail')
 {
     $_addcss = '';
     $_addrel = '';
     $_retval = '';
     /* if empty, set to default size, could be dropped later */
     if (empty($thumbsize)) {
         $thumbsize = 'thumbnail';
     }
     if ($order == 'random') {
         $r = new WP_Query("showposts={$_max}&what_to_show=posts&post_status=inherit&post_type=attachment&orderby=rand&post_mime_type=image/jpeg,image/gif,image/jpg,image/png");
     } else {
         $r = new WP_Query("showposts={$_max}&what_to_show=posts&post_status=inherit&post_type=attachment&orderby=menu_order ASC, ID ASC&post_mime_type=image/jpeg,image/gif,image/jpg,image/png");
     }
     if ($r->have_posts()) {
         $_retval = '<ul id="wGalleryId" class="wGallery">';
         while ($r->have_posts()) {
             $r->the_post();
             if (!empty($linkclass)) {
                 $_addcss = ' class="' . $linkclass . '"';
             }
             if (!empty($linkrel)) {
                 $_addrel = ' rel="' . $linkrel . '"';
             }
             $thumb = wp_get_attachment_image_src(get_the_ID(), $thumbsize);
             /////
             $url_template = get_template_directory_uri();
             //////
             if ($linktype == 'just display') {
                 $_retval .= '<li class="wGallery"><img src="' . wm_image_resize('180', '90', $thumb[0]) . '" alt="' . get_the_title() . '" title="' . get_the_title() . '"/></li>';
             } else {
                 $_retval .= '<li class="wGallery"><a href="' . $this->getImageLink(get_the_ID(), $linktype) . '"' . $_addcss . $_addrel . '><img src="' . wm_image_resize('180', '90', $thumb[0]) . '" alt="' . get_the_title() . '" title="' . get_the_title() . '"/></a></li>';
             }
         }
         $_retval .= '</ul>';
     }
     return $_retval;
 }
function kingsize_thumb_box($postid, $str_crop = '')
{
    global $no_of_page_columns;
    $lightbox = "true";
    $image_portfolio = get_post_meta($postid, 'upload_image', true);
    $video_thumb_image = get_post_meta($postid, 'upload_image_thumb', true);
    $video = get_post_meta($postid, 'kingsize_video_url', true);
    $height = get_post_meta($postid, 'kingsize_video_height', true);
    $embed = trim(get_post_meta($postid, 'kingsize_embed_code', true));
    if ($height == '') {
        $lightbox_height = 350;
    } else {
        $lightbox_height = $height + 20;
    }
    if ($image_portfolio != '') {
        $overview_image = $image_portfolio;
    } elseif ($video_thumb_image != '') {
        $overview_image = $video_thumb_image;
    } else {
        $overview_image = kingsize_get_the_post_thumbnail_url($postid);
    }
    //Added in V 4.1.3 to exclude the featured image into portfolio lightbox
    $exclude_featured = false;
    if (get_post_meta($postid, 'kingsize_exclude_portfolio_thumb', true) == 1) {
        $exclude_featured = true;
    } else {
        $exclude_featured = false;
    }
    #### Getting the attachments image items for portfoio V4 ####
    $args = array('post_type' => 'attachment', 'post_parent' => $postid, 'orderby' => "menu_order ID", 'order' => ASC);
    $attachments = get_children($args);
    ##### Getting the number of columns	#####
    if (empty($no_of_page_columns)) {
        $no_of_page_columns = "2columns";
    }
    if ($no_of_page_columns == "2columns") {
        $url_post_img = wm_image_resize('330', '220', $overview_image, $str_crop);
    } elseif ($no_of_page_columns == "3columns") {
        $url_post_img = wm_image_resize('220', '140', $overview_image, $str_crop);
    } elseif ($no_of_page_columns == "4columns") {
        $url_post_img = wm_image_resize('160', '110', $overview_image, $str_crop);
    } elseif ($no_of_page_columns == "grid") {
        $url_post_img = wm_image_resize('112', '112', $overview_image, $str_crop);
    }
    ###### End number of columns ######
    #### Getting the thumbnail ####
    if ($overview_image == '') {
        $thumb = get_the_post_thumbnail($postid, 'thumbnail-post');
    } else {
        $thumb = '<img src="' . $url_post_img . '"  title="' . get_the_title() . '"/>';
    }
    ###### SETTING of the portfolio thumbnail link #########
    if (get_post_meta($postid, 'portfolios_thumbnail_link', true) != '') {
        $lightbox = 'false';
        $permalink = get_post_meta($postid, 'portfolios_thumbnail_link', true);
    } else {
        $lightbox = 'true';
        $permalink = get_permalink($postid);
    }
    #### SETTING of Lightbox on Portfolio write up panel #######
    if (get_post_meta($postid, 'portfolios_lightbox_disable', true) == 'disable') {
        $lightbox = 'false';
    } else {
        $lightbox = 'true';
    }
    ####### CHECKING of lightbox effect is enabled or not ######
    if ($lightbox == 'true') {
        if ($embed != '') {
            // we get the width & height
            preg_match('/width="([0-9]+)"/', $embed, $matches_width);
            preg_match('/height="([0-9]+)"/', $embed, $matches_height);
            $height = $matches_height[1];
            $width = $matches_width[1];
            $output = '<a rel="prettyPhoto[gallery-' . $postid . ']" title="' . get_the_title($postid) . '" href="' . get_template_directory_uri() . '/lib/portfolio/kingsize-portfolio-video.php?id=' . $postid . '&iframe=true&width=' . $width . '&height=' . $height . '" class="video">' . $thumb . '</a>';
        } elseif ($video != '' && $embed == '') {
            $output = '<a rel="prettyPhoto[gallery-' . $postid . ']" title="' . get_the_title($postid) . '" href="' . $video . '" class="video">' . $thumb . '</a>';
        } else {
            ####### Getting the file name ########
            //patched in 4.1 thumbnail not showing in lightbox correct size
            $attachment_id = kingsize_get_attachment_id_from_url($overview_image);
            $image_attributes = wp_get_attachment_image_src($attachment_id, "full");
            if ($image_attributes["0"] != '') {
                $image_path = $image_attributes["0"];
            } else {
                $image_path = $overview_image;
            }
            //Added in V 4.1.3 to exclude the portfolio thumb
            if ($exclude_featured == true) {
                if ($attachments) {
                    $i = 0;
                    $featured_exclude_img_fst = "";
                    $featured_exclude_attachID_fst = "";
                    foreach ($attachments as $attachment) {
                        if ($attachment_id != $attachment->ID) {
                            if ($i == 0) {
                                //Image URL
                                $featured_exclude_attachID_fst = $attachment->ID;
                                $featured_exclude_img_fst = wp_get_attachment_url($attachment->ID);
                                //Title and Description
                                if (!empty($attachment->post_content)) {
                                    $post_title = $attachment->post_title . "<p>" . strip_tags($attachment->post_content) . "</p>";
                                } else {
                                    $post_title = $attachment->post_title;
                                }
                                if (get_post_meta($attachment->ID, '_wp_attachment_image_alt', true) == "") {
                                    $post_alt = $attachment->post_title;
                                } else {
                                    $post_alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true);
                                }
                            }
                            $i++;
                        }
                    }
                    $output = '<a rel="prettyPhoto[gallery-' . $postid . ']" title="' . $post_title . '" href="' . $featured_exclude_img_fst . '" class="image">' . $thumb . '</a>';
                }
            } else {
                $attachment = get_post($attachment_id);
                //Title and Description
                if (!empty($attachment->post_content)) {
                    $post_title = $attachment->post_title . "<p>" . strip_tags($attachment->post_content) . "</p>";
                } else {
                    $post_title = $attachment->post_title;
                }
                if (get_post_meta($attachment->ID, '_wp_attachment_image_alt', true) == "") {
                    $post_alt = $attachment->post_title;
                } else {
                    $post_alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true);
                }
                $output = '<a rel="prettyPhoto[gallery-' . $postid . ']" title="' . $post_title . '" href="' . $image_path . '" class="image">' . $thumb . '</a>';
            }
        }
        #### Getting the attachments image items for portfoio V4 ####
        if ($attachments) {
            $i = 0;
            foreach ($attachments as $attachment) {
                if ($exclude_featured == true) {
                    if ($featured_exclude_attachID_fst != $attachment->ID && $attachment_id != $attachment->ID) {
                        //Title and Description
                        if (!empty($attachment->post_content)) {
                            $post_title = $attachment->post_title . "<p>" . strip_tags($attachment->post_content) . "</p>";
                        } else {
                            $post_title = $attachment->post_title;
                        }
                        if (get_post_meta($attachment->ID, '_wp_attachment_image_alt', true) == "") {
                            $post_alt = $attachment->post_title;
                        } else {
                            $post_alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true);
                        }
                        $url_post_img = wm_image_resize('330', '220', wp_get_attachment_url($attachment->ID), $str_crop);
                        $output .= '<ul style="display:none;"><li><a href="' . wp_get_attachment_url($attachment->ID) . '" title="' . $post_title . '" rel="prettyPhoto[gallery-' . $postid . ']"><img  src="' . $url_post_img . '"  title="' . $post_title . '" /></a></li></ul>';
                    }
                } else {
                    //exclude has been not checked for feature image
                    if ($attachment_id != $attachment->ID) {
                        //Title and Description
                        if (!empty($attachment->post_content)) {
                            $post_title = $attachment->post_title . "<p>" . strip_tags($attachment->post_content) . "</p>";
                        } else {
                            $post_title = $attachment->post_title;
                        }
                        if (get_post_meta($attachment->ID, '_wp_attachment_image_alt', true) == "") {
                            $post_alt = $attachment->post_title;
                        } else {
                            $post_alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true);
                        }
                        $url_post_img = wm_image_resize('330', '220', wp_get_attachment_url($attachment->ID), $str_crop);
                        $output .= '<ul style="display:none;"><li><a href="' . wp_get_attachment_url($attachment->ID) . '" title="' . $post_title . '" rel="prettyPhoto[gallery-' . $postid . ']"><img  src="' . $url_post_img . '"  title="' . $post_title . '" /></a></li></ul>';
                    }
                }
            }
        }
        #### End attachments image items for portfoio V4 #######
    } else {
        $output = '<a title="' . get_the_title($postid) . '" href="' . $permalink . '" class="custom-port">' . $thumb . '</a>';
    }
    echo $output;
}
function gallery_shortcodes($atts, $content = null)
{
    global $data;
    extract(shortcode_atts(array('id' => false, 'type' => false, 'layout' => false, 'orderby' => false, 'order' => false, 'description' => false, 'placement' => false, 'crop' => "center"), $atts));
    // variable setup
    $post_id = $id ? $id : '';
    $gallery_type = $type ? $type : 'prettyphoto';
    $layout = $layout ? $layout : 2;
    $order = $order ? $order : 'ASC';
    $orderby = $orderby ? $orderby : 'custom_id';
    $description = $description ? $description : '';
    $placement = $placement ? $placement : 'above';
    $crop = $crop ? $crop : 'center';
    //croping
    $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 ////////
    //order by
    if ($orderby == 'random') {
        $orderby = 'rand';
    } elseif ($orderby == 'menu_order' || $orderby == 'custom_id') {
        $orderby = 'menu_order ID';
    } elseif ($orderby == 'asc_order') {
        $orderby = 'date';
    } else {
        $orderby = 'menu_order ID';
    }
    //if no post id defined return blank
    if ($post_id == '') {
        return false;
    }
    if ($layout == "grid") {
        $no_of_page_columns = "grid";
    } elseif ($layout == "2") {
        $no_of_page_columns = "2columns";
    } elseif ($layout == "3") {
        $no_of_page_columns = "3columns";
    } elseif ($layout == "4") {
        $no_of_page_columns = "4columns";
    }
    // Add Gallery type JS and CSS
    global $tpl_body_id;
    if ($tpl_body_id != "blog_overview") {
        ##fix the blog overview page error.
        $tpl_body_id = $gallery_type;
    }
    // Apply Gallery Type
    if ($gallery_type == "colorbox") {
        $relative_gal = 'gallery-' . $post_id;
    } elseif ($gallery_type == "prettyphoto") {
        $relative_gal = 'prettyPhoto[gallery-' . $post_id . ']';
    } elseif ($gallery_type == "fancybox") {
        $relative_gal = 'gallery-' . $post_id;
    }
    //<!-- Gallery start here -->
    ##### Enable/Disabled Gallery Title #####
    $showTitle = false;
    if ($gallery_type == "colorbox" && $data["wm_gallery_titles_colorbox"] == "Enable Colorbox Titles") {
        $showTitle = true;
    } elseif ($gallery_type == "fancybox" && $data["wm_gallery_titles_fancybox"] == "Enable Fancybox Titles") {
        $showTitle = true;
    } elseif ($gallery_type == "prettyphoto" && $data["wm_gallery_titles_prettyphoto"] == "Enable PrettyPhoto Titles") {
        $showTitle = true;
    } elseif ($gallery_type == "galleria" && $data["wm_gallery_titles_galleria"] == "Enable Galleria Titles") {
        $showTitle = true;
    } elseif ($gallery_type == "slideviewer" && $data["wm_gallery_titles_slideviewer"] == "Enable SlideViewer Titles") {
        $showTitle = true;
    }
    ##### END Enable/Disabled Gallery Title #####
    #### getting the page Gallery attachments images ####
    $args = array('post_type' => 'attachment', 'post_parent' => $post_id, 'orderby' => $orderby, 'order' => $order);
    $attachments = get_children($args);
    ob_start();
    $url_post_img = "";
    if ($gallery_type == "colorbox" || $gallery_type == "prettyphoto" || $gallery_type == "fancybox") {
        if ($description && $placement == "above") {
            echo '<p>' . $description . '</p>';
        }
        ?>
<div id="gallery_<?php 
        echo $gallery_type;
        ?>
" class="gallery">	
   <ul class="gallery_<?php 
        echo $no_of_page_columns;
        ?>
 gallery_shortcode <?php 
        if ($layout == "2") {
            echo ' 2col_shortcode';
        }
        ?>
">							
	<?php 
        if ($attachments) {
            foreach ($attachments as $attachment) {
                if ($no_of_page_columns == "2columns") {
                    $url_post_img = wm_image_resize('330', '220', wp_get_attachment_url($attachment->ID), $str_crop);
                } elseif ($no_of_page_columns == "3columns") {
                    $url_post_img = wm_image_resize('220', '140', wp_get_attachment_url($attachment->ID), $str_crop);
                } elseif ($no_of_page_columns == "4columns") {
                    $url_post_img = wm_image_resize('160', '110', wp_get_attachment_url($attachment->ID), $str_crop);
                } elseif ($no_of_page_columns == "grid") {
                    $url_post_img = wm_image_resize('112', '112', wp_get_attachment_url($attachment->ID), $str_crop);
                }
                if ($gallery_type == "prettyphoto" && !empty($attachment->post_content)) {
                    $post_title = "<p>" . strip_tags($attachment->post_content) . "</p>";
                } elseif (!empty($attachment->post_content)) {
                    $post_title = $attachment->post_title . "<p>" . strip_tags($attachment->post_content) . "</p>";
                } else {
                    $post_title = $attachment->post_title;
                }
                if (get_post_meta($attachment->ID, '_wp_attachment_image_alt', true) == "") {
                    $post_alt = $attachment->post_title;
                } else {
                    $post_alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true);
                }
                ?>
			<li><a href="<?php 
                echo wp_get_attachment_url($attachment->ID);
                ?>
" class="image" title="<?php 
                echo $post_title;
                ?>
" rel="<?php 
                echo $relative_gal;
                ?>
"><img  src="<?php 
                echo $url_post_img;
                ?>
" alt="<?php 
                echo $post_alt;
                ?>
" title="<?php 
                echo $attachment->post_title;
                ?>
"/></a></li>									
	<?php 
            }
        }
        ?>
								
	</ul>	
</div>	
<div class="clear"></div>
<?php 
    } elseif ($gallery_type == "galleria") {
        ?>
<!-- Galleria - place you images here -->
	<div id="gallery_galleria" class="galleria">    					   					
		<?php 
        //getting the page Gallery attachments images
        if ($attachments) {
            foreach ($attachments as $attachment) {
                $url_post_img = wm_image_resize('680', '450', wp_get_attachment_url($attachment->ID), $str_crop);
                if (!empty($attachment->post_content)) {
                    $post_title = $attachment->post_title . "<p>" . strip_tags($attachment->post_content) . "</p>";
                } elseif (get_post_meta($attachment->ID, '_wp_attachment_image_alt', true) == "") {
                    $post_title = $attachment->post_title;
                } else {
                    $post_title = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true);
                }
                if (get_post_meta($attachment->ID, '_wp_attachment_image_alt', true) == "") {
                    $post_alt = $attachment->post_title;
                } else {
                    $post_alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true);
                }
                echo '<img title="' . $post_title . '" data-title="' . $post_title . '"  src="' . $url_post_img . '"/>';
            }
        }
        ?>
	
	</div>	
<div class="clear"></div>
<!-- Galleria ends here -->
<?php 
    } elseif ($gallery_type == "slideviewer") {
        ?>
<!-- slideviewer - place you images here -->
	 <div id="gallery_slideviewer" class="swv">  
		<ul class="gallery_shortcode_slideviewer">
			<?php 
        if ($attachments) {
            foreach ($attachments as $attachment) {
                $url_post_img = wm_image_resize('670', '450', wp_get_attachment_url($attachment->ID), $str_crop);
                $post_title = $attachment->post_title;
                if (get_post_meta($attachment->ID, '_wp_attachment_image_alt', true) == "") {
                    $post_alt = $attachment->post_title;
                } else {
                    $post_alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true);
                }
                if ($showTitle == true) {
                    echo '<li><img alt="' . $post_alt . '" title="' . $post_title . '" src="' . $url_post_img . '" /></li>';
                } else {
                    echo '<li><img alt="' . $post_alt . '" title="" src="' . $url_post_img . '" /></li>';
                }
            }
        }
        ?>
	
			</ul>
		</div>
<div class="clear"></div>	
<!-- slideviewer ends here -->
<?php 
    }
    //<!-- Gallery ends here -->
    if ($description && $placement == "below") {
        echo '<p>' . $description . '</p>';
    }
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}
function shortcode_blog($atts, $content = null)
{
    global $postParentPageID;
    extract(shortcode_atts(array('cats' => '', 'featured_images' => 'true', 'per_page' => '5', 'orderby' => 'date', 'order' => 'desc', 'offset' => '0', 'title' => 'true', 'meta_data' => 'true', 'content_display' => 'excerpt', 'pagination' => 'true'), $atts));
    global $wp_query, $data;
    // 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
    $args = array('post_type' => 'post', 'post_status' => 'publish', 'cat' => $cats, 'paged' => $paged, 'caller_get_posts' => 1, 'orderby' => $orderby, 'order' => $order, 'posts_per_page' => $per_page, 'offset' => $offset);
    $featured_query = new wp_query($args);
    ob_start();
    ?>
	
	<?php 
    while ($featured_query->have_posts()) {
        $featured_query->the_post();
        $counter = $counter + 1;
        ?>
				<div class="post">
				   <?php 
        if ($title == 'true') {
            ?>
					   <h3 class="post_title">
						 <a title="<?php 
            the_title();
            ?>
" href="<?php 
            the_permalink();
            ?>
"><?php 
            the_title();
            ?>
</a>
					   </h3>
					<?php 
        }
        ?>
	
					<!-- Post details -->
					<?php 
        if ($meta_data == 'true') {
            ?>
						<div class="metadata">
							<?php 
            if ($data['wm_date_enabled'] == '1') {
                //data is enabled
                ?>
							<p class="post_date"><?php 
                the_time(get_option('date_format'));
                ?>
</p>
							<?php 
            }
            ?>
							
							<?php 
            if ($data['wm_meta_comments_enabled'] == '1') {
                //data is enabled
                ?>
							<a href="<?php 
                the_permalink();
                ?>
#comments" class="post_comments"><?php 
                comments_number(__('No comments', 'kslang'), __('1 comment', 'kslang'), __('% comments', 'kslang'));
                ?>
</a>
							<?php 
            }
            ?>
						</div>
					<?php 
        }
        ?>

					<!-- Post thubmnail -->	
					<?php 
        $postid = $featured_query->post->ID;
        if ($featured_images == 'true') {
            //show the image in lightbox
            $show_image_lightbox = get_post_meta($postid, 'kingsize_featured_img_lightbox', true);
            //POST featured image height
            if (get_post_meta($postid, 'kingsize_post_featured_img_height', true)) {
                $post_featured_img_height = get_post_meta($postid, 'kingsize_post_featured_img_height', true);
            } else {
                $post_featured_img_height = 180;
            }
            //Sidebar enabled
            if ($data['wm_page_sidebar_enabled'] == "1" && (get_post_meta($postParentPageID, 'page_sidebar_hide', true) == "" && get_post_type($postParentPageID) == 'page')) {
                $post_featured_img_width = 460;
            } elseif ($data['wm_page_sidebar_enabled'] == "1" && (get_post_meta($postParentPageID, 'post_sidebar_hide', true) == "" && get_post_type($postParentPageID) == 'post')) {
                $post_featured_img_width = 460;
            } else {
                $post_featured_img_width = 680;
            }
            if (has_post_thumbnail()) {
                // POST has thumbnail
                $org_img_url = wp_get_attachment_url(get_post_thumbnail_id($postid));
                $attachment_id = get_post_thumbnail_id($postid);
                $url_post_img = wm_image_resize($post_featured_img_width, $post_featured_img_height, wp_get_attachment_url($attachment_id));
                if ($show_image_lightbox == 'enable') {
                    echo '<a href="' . $org_img_url . '" class="image lightbox_blog" title="' . get_the_title() . '" rel="gallery"><img src="' . $url_post_img . '" alt="' . get_the_title() . '" class="blog_thumbnail"/></a>';
                } else {
                    echo '<a href="' . get_permalink($postid) . '" class="image" title="' . get_the_title() . '"><img src="' . $url_post_img . '" alt="' . get_the_title() . '" class="blog_thumbnail"/></a>';
                }
            }
        }
        ?>
					<!-- END Post thubmnail -->							

					<!-- POST Content -->
					<?php 
        ///Enable the gallery with next previous of images
        if ($content_display == 'excerpt') {
            //when content_display='excerpt'
            echo get_the_content_with_formatting($data['wm_read_more_text']);
        } elseif ($content_display == 'rtf') {
            //when content_display='gallery'
            global $more;
            $more = 0;
            the_content($data['wm_read_more_text']);
        } elseif ($content_display == '' || $content_display == 'full') {
            //show full content when content_display='full'
            $post_content = get_content();
            $post_content = str_replace("(more...)", $data['wm_read_more_text'], $post_content);
            $post_content = str_replace("(more&#8230;)", $data['wm_read_more_text'], $post_content);
            echo $post_content;
        }
        ?>
					<!-- POST Content END -->
											
				</div>

	  <?php 
    }
    ?>

<?php 
    if ($pagination == "true") {
        kingsize_pagination($featured_query->max_num_pages);
    }
    $output_string = ob_get_contents();
    ob_end_clean();
    wp_reset_postdata();
    return $output_string;
}