function widget($args, $instance) { global $post; extract($args); // Widget Options $title = apply_filters('widget_title', $instance['title']); // Title $number = $instance['number']; // Number of posts to show echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } $recent_portfolio = new WP_Query(array('post_type' => 'portfolio', 'posts_per_page' => $number)); if ($recent_portfolio->have_posts()) { ?> <ul class="recent-posts-list portfolio-list"> <?php while ($recent_portfolio->have_posts()) { $recent_portfolio->the_post(); $post_title = get_the_title(); $post_permalink = get_permalink(); $thumb_image = get_post_thumbnail_id(); $thumb_img_url = wp_get_attachment_url($thumb_image, 'widget-image'); $image = tx_image_resize($thumb_img_url, 94, 75, true, false); ?> <li> <a href="<?php echo $post_permalink; ?> " class="recent-post-image"> <?php if ($image) { ?> <img src="<?php echo $image['url']; ?> " width="<?php echo $image[1]; ?> " height="<?php echo $image[2]; ?> " alt=" " /> <?php } ?> </a> <div class="recent-post-details"> <a class="recent-post-title" href="<?php echo $post_permalink; ?> " title="<?php echo $post_title; ?> "><?php echo $post_title; ?> </a> </div> </li> <?php wp_reset_query(); } ?> </ul> <?php } ?> <?php echo $after_widget; }
function tx_slider_function($atts, $content = null) { $atts = shortcode_atts(array('items' => 10, 'category' => '', 'delay' => 8000, 'class' => ''), $atts); $return_string = ''; $cat_slug = ''; if (!empty($atts['category'])) { $cat_slug = $atts['category']; } $posts_per_page = intval($atts['items']); $tx_class = $atts['class']; $tx_delay = $atts['delay']; $return_string .= '<div class="tx-slider" data-delay="' . $tx_delay . '">'; wp_reset_query(); global $post; $args = array('post_type' => 'itrans-slider', 'posts_per_page' => $posts_per_page, 'orderby' => 'date', 'order' => 'DESC', 'ignore_sticky_posts' => 1, 'itrans-slider-category' => $cat_slug); $full_image_url = ''; $large_image_url = ''; $image_url = ''; $width = 1200; $height = 420; query_posts($args); if (have_posts()) { while (have_posts()) { the_post(); $full_image_url = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full'); $large_image_url = wp_get_attachment_image_src(get_post_thumbnail_id(), 'large'); $image_url = tx_image_resize($full_image_url[0], $width, $height, true, true); $slide_link_text = rwmb_meta('tx_slide_link_text'); $show_link_url = rwmb_meta('tx_slide_link_url'); $return_string .= '<div class="tx-slider-item">'; $return_string .= '<div class="tx-slider-box">'; if (has_post_thumbnail()) { $return_string .= '<div class="tx-slider-img"><a href="' . esc_url($large_image_url[0]) . '" class="tx-colorbox">'; $return_string .= '<img src="' . esc_url($image_url["url"]) . '" alt="" class="blog-image" /></a>'; $return_string .= '</div>'; } /**/ $return_string .= '<div class="tx-slide-content"><div class="tx-slide-content-inner">'; $return_string .= '<h3 class="tx-slide-title">' . get_the_title() . '</h3>'; $return_string .= '<div class="tx-slide-details"><p>' . tx_custom_excerpt(32) . '</p></div>'; $return_string .= '<div class="tx-slide-button"><a href="' . esc_url($show_link_url) . '">' . esc_attr($slide_link_text) . '</a></div>'; $return_string .= '</div></div></div></div>'; } } else { $return_string .= '<p>Sorry, no slider matched your criteria.</p>'; } $return_string .= '</div>'; wp_reset_query(); return $return_string; }
function widget($args, $instance) { global $post; extract($args); // Widget Options $title = apply_filters('widget_title', $instance['title']); // Title $number = $instance['number']; // Number of posts to show echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } $atts['posts_per_page'] = $number; $atts['post_type'] = 'post'; $atts['ignore_sticky_posts'] = 1; $recent_posts = new WP_Query($atts); /* $recent_posts = new WP_Query( array( 'post_type' => 'post', 'posts_per_page' => 5, 'post_count' => 5, 'post_status' => 'publish' ) ); */ if ($recent_posts->have_posts()) { ?> <ul class="recent-posts-list"> <?php while ($recent_posts->have_posts()) { $recent_posts->the_post(); $thumb_stat = ""; $post_title = get_the_title(); $post_author = get_the_author_link(); $post_date = get_the_date('M j, Y'); $post_categories = get_the_category_list(); $post_comments = get_comments_number(); $post_permalink = get_permalink(); $thumb_image = get_post_thumbnail_id(); $thumb_img_url = wp_get_attachment_url($thumb_image, 'small'); $image = tx_image_resize($thumb_img_url, 96, 96, true, false); if ($image) { $thumb_stat = "thumbyes"; } else { $thumb_stat = "thumbno"; } ?> <li class="clearfix nx-recent-post"> <a href="<?php echo $post_permalink; ?> " class="recent-post-image"> <?php if ($image) { ?> <img src="<?php echo $image['url']; ?> " alt=" " /> <?php } ?> </a> <div class="recent-post-details <?php echo $thumb_stat; ?> "> <a class="recent-post-title" href="<?php echo $post_permalink; ?> " title="<?php echo $post_title; ?> "><?php echo $post_title; ?> </a> <span class="post-meta"><?php printf(__('By %1$s on %2$s', 'tx'), $post_author, $post_date); ?> </span> </div> </li> <?php wp_reset_query(); } ?> </ul> <?php } ?> <?php echo $after_widget; }
function widget($args, $instance) { global $post; extract($args); // Widget Options $title = apply_filters('widget_title', $instance['title']); // Title $number = $instance['number']; // Number of posts to show echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } $recent_portfolio = new WP_Query(array('post_type' => 'portfolio', 'posts_per_page' => $number)); $count = 0; if ($recent_portfolio->have_posts()) { ?> <ul class="portfolio-grid clearfix"> <?php while ($recent_portfolio->have_posts()) { $recent_portfolio->the_post(); $post_title = get_the_title(); $post_permalink = get_permalink(); $thumb_image = get_post_thumbnail_id(); $thumb_img_url = wp_get_attachment_url($thumb_image, 'small'); $image = tx_image_resize($thumb_img_url, 96, 96, true, false); ?> <?php if ($image) { ?> <li class="grid-item-<?php echo $count; ?> "> <a href="<?php echo $post_permalink; ?> " class="grid-image tooltip2" title="<?php echo $post_title; ?> "> <img src="<?php echo $image['url']; ?> " width="<?php echo $image[1]; ?> " alt="<?php echo $post_title; ?> " /> </a> </li> <?php } ?> <?php $count++; wp_reset_query(); } ?> </ul> <?php } ?> <?php echo $after_widget; }