function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); $categories = empty($instance['categories']) ? $instance['categories'] : implode($instance['categories'], ','); $count = empty($instance['count']) ? 5 : $instance['count']; $limit = empty($instance['limit']) ? 100 : $instance['limit']; $show_thumbnails = $instance['show_thumbnails']; $show_excerpt = $instance['show_excerpt']; $all_post_formats = $instance['all_post_formats']; $thumb_width = empty($instance['thumb_width']) ? 50 : $instance['thumb_width']; $thumb_height = empty($instance['thumb_height']) ? 50 : $instance['thumb_height']; //remove aside and quote post formats from the list $postargs = $all_post_formats ? array('orderby' => 'comment_count', 'post_type' => 'post', 'showposts' => $count, 'cat' => $categories, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => 1) : array('orderby' => 'comment_count', 'tax_query' => array(array('operator' => 'NOT IN', 'taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array('post-format-quote', 'post-format-aside'))), 'post_type' => 'post', 'showposts' => $count, 'cat' => $categories, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => 1); $post_query = new WP_Query($postargs); $rt_posts = '<div class="recent_posts clearfix"><ul>'; if ($post_query->have_posts()) { while ($post_query->have_posts()) { $post_query->the_post(); $post_title = get_the_title(); $link = get_permalink(); $date = get_the_time('d M Y'); $comment_count = get_comment_count($post_query->post->ID); $rt_gallery_images = get_post_meta($post_query->post->ID, THEMESLUG . "rt_gallery_images", true) ? get_post_meta($post_query->post->ID, THEMESLUG . "rt_gallery_images", true) : ""; $rt_gallery_image_titles = get_post_meta($post_query->post->ID, THEMESLUG . "rt_gallery_image_titles", true) ? get_post_meta($post_query->post->ID, THEMESLUG . "rt_gallery_image_titles", true) : ""; $rt_gallery_image_descs = get_post_meta($post_query->post->ID, THEMESLUG . "rt_gallery_image_descs", true) ? get_post_meta($post_query->post->ID, THEMESLUG . "rt_gallery_image_descs", true) : ""; $fist_featured_image = is_array($rt_gallery_images) ? find_image_org_path($rt_gallery_images[0]) : ""; $rt_posts .= '<li class="clearfix">'; if ($fist_featured_image && !$show_thumbnails) { $f_image = @vt_resize('', $fist_featured_image, $thumb_width, $thumb_height, true); if ($f_image["url"]) { $rt_posts .= '<img src="' . $f_image["url"] . '" alt="' . $title . '" class="recent-posts-thumb" />'; } } $rt_posts .= '<span class="date">' . $date . '</span>'; $rt_posts .= '<span class="title"><a href="' . $link . '">' . $post_title . '</a></span>'; $rt_posts .= $show_excerpt ? '' . wp_html_excerpt(get_the_excerpt(), $limit) . '...' : ""; if ($comment_count['approved'] > 0) { if ($comment_count['approved'] > 1) { $comments = $comment_count['approved'] . ' ' . __('Comments', 'rt_theme'); } else { $comments = __('1 Comment', 'rt_theme'); } $rt_posts .= ' <span class="comment_number date"><a href="' . get_comments_link() . '" title="' . $comments . '" class="comment_link">' . $comments . '</a></span>'; $rt_posts .= $show_excerpt ? '<div class="space margin-b10"></div>' : ""; } $rt_posts .= '</li>'; } } wp_reset_query(); $rt_posts .= '</ul></div>'; echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } echo $rt_posts; echo $after_widget; }
if (have_posts()) { while (have_posts()) { the_post(); ?> <?php # # post variables # //featured images $rt_gallery_images = get_post_meta($post->ID, THEMESLUG . "rt_gallery_images", true) ? get_post_meta($post->ID, THEMESLUG . "rt_gallery_images", true) : ""; $rt_gallery_image_titles = get_post_meta($post->ID, THEMESLUG . "rt_gallery_image_titles", true) ? get_post_meta($post->ID, THEMESLUG . "rt_gallery_image_titles", true) : ""; $rt_gallery_image_descs = get_post_meta($post->ID, THEMESLUG . "rt_gallery_image_descs", true) ? get_post_meta($post->ID, THEMESLUG . "rt_gallery_image_descs", true) : ""; $fist_featured_image = is_array($rt_gallery_images) ? find_image_org_path($rt_gallery_images[0]) : ""; $featured_image_in_single_post_page = get_post_meta($post->ID, THEMESLUG . 'featured_image_in_single_post_page', true); //various $is_old_post = get_post_meta($post->ID, THEMESLUG . 'is_old_post', true) == "1" ? false : true; $resize = get_post_meta($post->ID, THEMESLUG . 'blog_image_resize', true) && $featured_image_in_single_post_page ? true : false; $crop = get_post_meta($post->ID, THEMESLUG . 'blog_image_crop', true) && $featured_image_in_single_post_page ? true : false; $width = get_post_meta($post->ID, THEMESLUG . 'blog_image_width', true) ? get_post_meta($post->ID, THEMESLUG . 'blog_image_width', true) : $image_width; $meta_height = get_post_meta($post->ID, THEMESLUG . 'blog_image_height', true); $height = !$meta_height && !$crop ? 10000 : ($meta_height && !$crop ? $meta_height : $meta_height && $crop ? $meta_height : $image_height); $img_position = get_post_meta($post->ID, THEMESLUG . 'featured_image_position', true) && $featured_image_in_single_post_page ? get_post_meta($post->ID, THEMESLUG . 'featured_image_position', true) : "center"; $post_class_img = "featured_image_" . $img_position; $featured_image_usage = get_post_meta($post->ID, THEMESLUG . '_featured_image_usage', true); $display_gallery_images = get_post_meta($post->ID, THEMESLUG . '_display_gallery_images', true); $photo_gallery_images_width = get_post_meta($post->ID, THEMESLUG . "photo_gallery_images_width", true) ? get_post_meta($post->ID, THEMESLUG . "photo_gallery_images_width", true) : 160; $photo_gallery_images_height = get_post_meta($post->ID, THEMESLUG . "photo_gallery_images_height", true) ? get_post_meta($post->ID, THEMESLUG . "photo_gallery_images_height", true) : 160; $imageURL = "";
echo '<div id="' . $randomClass . '">'; if (have_posts()) { while (have_posts()) { the_post(); # # Values # // Portfolio featured images $rt_gallery_images = get_post_meta($post->ID, THEMESLUG . "rt_gallery_images", true); $rt_gallery_image_titles = get_post_meta($post->ID, THEMESLUG . "rt_gallery_image_titles", true); $rt_gallery_image_descs = get_post_meta($post->ID, THEMESLUG . "rt_gallery_image_descs", true); // other values $image = is_array($rt_gallery_images) ? find_image_org_path($rt_gallery_images[0]) : ""; $title = get_the_title(); $video = str_replace("&", "&", get_post_meta($post->ID, 'rttheme_portfolio_video', true)); $video_thumbnail = find_image_org_path(get_post_meta($post->ID, 'rttheme_portfolio_video_thumbnail', true)); $desc = get_post_meta($post->ID, 'rttheme_portfolio_desc', true); $permalink = get_permalink(); $remove_link = get_post_meta($post->ID, 'rttheme_portf_no_detail', true); $custom_thumb = get_post_meta($post->ID, 'rttheme_portfolio_thumb_image', true); $disable_lightbox = get_post_meta($post->ID, 'rttheme_disable_lightbox', true); $term_list = get_the_terms($post->ID, 'portfolio_categories'); // selected term list of each post $portfolio_format = get_post_meta($post->ID, 'rttheme_portfolio_post_format', true); $external_link = get_post_meta($post->ID, 'rttheme_external_link', true); $open_in_new_tab = get_post_meta($post->ID, 'rttheme_open_in_new_tab', true); $media_link = ""; $target = ""; //box counter if (!isset($box_counter)) { $box_counter = 1;
<?php if (have_posts()) { while (have_posts()) { the_post(); ?> <?php // Portfolio featured images $rt_gallery_images = get_post_meta($post->ID, THEMESLUG . "rt_gallery_images", true); $rt_gallery_image_titles = get_post_meta($post->ID, THEMESLUG . "rt_gallery_image_titles", true); $rt_gallery_image_descs = get_post_meta($post->ID, THEMESLUG . "rt_gallery_image_descs", true); // Values $title = get_the_title(); $video = get_post_meta($post->ID, 'rttheme_portfolio_video', true); $video_thumbnail = get_post_meta($post->ID, 'rttheme_portfolio_video_thumbnail', true); $image = is_array($rt_gallery_images) ? find_image_org_path($rt_gallery_images[0]) : ""; $desc = get_post_meta($post->ID, 'rttheme_portfolio_desc', true); $permalink = get_permalink(); $remove_link = get_post_meta($post->ID, 'rttheme_portf_no_detail', true); $custom_thumb = get_post_meta($post->ID, 'rttheme_portfolio_thumb_image', true); $project_info = get_post_meta($post->ID, 'rttheme_project_info', true); $featured_image_usage = get_post_meta($post->ID, 'rttheme_featured_image_usage', true); $post_uniqueID = 'portfolio-post-' . get_the_ID() . ''; $portfolio_format = get_post_meta($post->ID, 'rttheme_portfolio_post_format', true); $password_protected = post_password_required($post) ? true : false; // Password Protected //project key details to add before sidebar if (trim($project_info)) { $before_sidebar = '<div class="box first box-shadow box_layout widget project_notes">'; $before_sidebar .= '<div class="head_text nomargin"><div class="arrow"></div><h4>'; $before_sidebar .= get_post_meta($post->ID, 'rttheme_project_info_title', true);
function rt_shortcode_products($atts, $content = null) { global $post; //[product_showcase categories="product-category-1,product-category-2" columns="2" limit="2" desc="false" orderby="date" order="descending"] //defaults extract(shortcode_atts(array("ids" => '', "desc" => 'true', "categories" => "", "columns" => 4, "orderby" => "date", "order" => "descending", "limit" => 1000), $atts)); $products_showcase = ""; //fix column value if ($columns > 5 || $columns < 1 || !is_numeric(trim($columns))) { $columns = 4; } //pre-defined layout values $layout_values = array("5" => array("name" => "five", "w" => 440, "h" => 300), "4" => array("name" => "four", "w" => 440, "h" => 300), "3" => array("name" => "three", "w" => 440, "h" => 300), "2" => array("name" => "two", "w" => 440, "h" => 300), "1" => array("name" => "one", "w" => 940, "h" => 500)); //selected column values $selected_column_values = $layout_values[$columns]; //product id numbders $ids = trim($ids) ? explode(",", trim($ids)) : array(); //product category slugs $categoriesArray = trim($categories) ? explode(",", trim($categories)) : array(); //Product sliderID $product_sliderID = 'product_slider_' . rand(1000, 1000000); //fix shortcode $content = do_shortcode(fixshortcode($content)); $content = preg_replace('#<br \\/>#', "", trim($content)); $content = preg_replace('#<p>#', "", trim($content)); $content = preg_replace('#<\\/p>#', "", trim($content)); $slideCounter = 1; if ($ids) { //ids provided $queryProducts = new WP_Query(array('post_type' => 'products', 'post_status' => 'publish', 'orderby' => $orderby, 'order' => $order, 'post__in' => $ids, 'showposts' => $limit)); } else { //product slugs provided $queryProducts = new WP_Query(array('post_type' => 'products', 'post_status' => 'publish', 'orderby' => $orderby, 'order' => $order, 'showposts' => $limit, 'tax_query' => array(array('taxonomy' => 'product_categories', 'field' => 'slug', 'terms' => $categoriesArray, 'operator' => "IN")))); } $products_showcase .= '<div class="products-row">'; if ($queryProducts->have_posts()) { while ($queryProducts->have_posts()) { $queryProducts->the_post(); // featured images $rt_gallery_images = get_post_meta($post->ID, THEMESLUG . "rt_gallery_images", true); $rt_gallery_image_titles = get_post_meta($post->ID, THEMESLUG . "rt_gallery_image_titles", true); $rt_gallery_image_descs = get_post_meta($post->ID, THEMESLUG . "rt_gallery_image_descs", true); //values $title = get_the_title(); $thumb = is_array($rt_gallery_images) ? find_image_org_path($rt_gallery_images[0]) : ""; $image = @vt_resize('', $thumb, $selected_column_values["w"], $selected_column_values["h"], 'true'); $short_desc = get_post_meta($post->ID, THEMESLUG . 'short_description', true); $permalink = get_permalink(); $class = ""; if (fmod($slideCounter, $columns) == 0) { $class = "last"; } if (fmod($slideCounter, $columns) == 1) { $class = "first"; } $products_showcase .= '<div class="box product ' . $selected_column_values["name"] . ' ' . $class . '">'; //thumbnail if ($thumb) { $products_showcase .= '<span class="frame block"><a href="' . $permalink . '" class="imgeffect link"><img src="' . $image['url'] . '" alt="" /></a></span>'; } $products_showcase .= '<div class="product_info">'; //title $products_showcase .= '<h5><a href="' . $permalink . '" title="' . $title . '">' . $title . '</a></h5>'; //desc if ($desc != "false") { $products_showcase .= do_shortcode($short_desc); } $products_showcase .= '</div>'; $products_showcase .= '</div>'; if (fmod($slideCounter, $columns) == 0 || $queryProducts->post_count == $slideCounter) { if ($desc != "false") { $products_showcase .= '<div class="space margin-b30"></div>'; } else { $products_showcase .= '<div class="space margin-b10"></div>'; } } $slideCounter++; } } $products_showcase .= '</div>'; wp_reset_query(); return $products_showcase; }