public function get_posts_result($args) { $slide_image_target = isset($args['image_from']) ? $args['image_from'] : 'auto'; $th_wp_query = $this->get_query_results($args); ob_start(); if ($th_wp_query->have_posts()) { while ($th_wp_query->have_posts()) { $th_wp_query->the_post(); $the_excerpt = get_the_excerpt(); $excerpt_length = isset($args['excerpt_length']) ? $args['excerpt_length'] : ''; if (!empty($excerpt_length)) { $the_excerpt = msp_get_trimmed_string(get_the_excerpt(), (int) $excerpt_length); } $the_media = ''; $the_media_src = msp_get_auto_post_thumbnail_src($th_wp_query->post->ID, $slide_image_target); if (!empty($the_media_src)) { $the_media_tag = msp_get_the_resized_image($the_media_src, 80, 80, true, 100); $the_media = sprintf('<div class="msp-entry-media" ><a href="%s" target="_blank">%s</a></div>', get_the_permalink(), $the_media_tag); } ?> <article class="msp-post msp-post-<?php echo $th_wp_query->post->ID; ?> msp-post-<?php echo $th_wp_query->post->post_type; ?> "> <figure> <?php echo $the_media; ?> <figcaption> <div class="msp-entry-header"> <h4 class="msp-entry-title"><a href="<?php the_permalink(); ?> " target="_blank"><?php the_title(); ?> </a></h4> </div> <div class="msp-entry-content"> <time datetime="<?php the_time('Y-m-d'); ?> " title="<?php the_time('Y-m-d'); ?> " ><?php the_time('F j, Y'); ?> </time> ( <span class="ps-post-id">Post ID: <?php the_ID(); ?> </span> ) <p><?php echo $the_excerpt; ?> </p> </div> </figcaption> </figure> </article> <?php } } return ob_get_clean(); }
public function get_posts_result($args) { $slide_image_target = isset($args['image_from']) ? $args['image_from'] : 'auto'; $th_wp_query = $this->get_query_results($args); ob_start(); if ($th_wp_query->have_posts()) { while ($th_wp_query->have_posts()) { $th_wp_query->the_post(); $product = get_product($th_wp_query->post->ID); $the_excerpt = apply_filters('woocommerce_short_description', $product->get_post_data()->post_excerpt); $excerpt_length = isset($args['excerpt_length']) ? $args['excerpt_length'] : ''; if (!empty($excerpt_length)) { $the_excerpt = msp_get_trimmed_string($the_excerpt, (int) $excerpt_length); } $the_media = ''; $the_media_src = msp_get_auto_post_thumbnail_url($th_wp_query->post->ID, $slide_image_target); $premalink = $product->get_permalink(); if (!empty($the_media_src)) { $the_media_tag = msp_get_the_resized_image($the_media_src, 80, 80, true, 100); $the_media = sprintf('<div class="msp-entry-media" ><a href="%s" target="_blank">%s</a></div>', $premalink, $the_media_tag); } ?> <article class="msp-post msp-post-<?php echo $th_wp_query->post->ID; ?> msp-post-<?php echo $th_wp_query->post->post_type; ?> "> <figure> <?php echo $the_media; ?> <figcaption> <div class="msp-entry-header"> <h4 class="msp-entry-title"><a href="<?php echo $premalink; ?> " target="_blank"><?php the_title(); ?> </a></h4> </div> <div class="msp-entry-content"> <time datetime="<?php the_time('Y-m-d'); ?> " title="<?php the_time('Y-m-d'); ?> " ><?php the_time('F j, Y'); ?> </time> ( <span class="ps-post-id">Post ID: <?php the_ID(); ?> </span> ) <?php if ($regular_price = wc_format_decimal($product->get_regular_price(), 2)) { ?> ( <span class="regular-price"><?php _e('Regular Price', MSWP_TEXT_DOMAIN); echo ': ' . $regular_price; ?> </span> ) <?php } ?> <?php if ($sale_price = $product->get_sale_price() ? wc_format_decimal($product->get_sale_price(), 2) : null) { ?> ( <span class="sale-price"><?php _e('Sale Price', MSWP_TEXT_DOMAIN); echo ': ' . $sale_price; ?> </span> ) <?php } ?> <p><?php echo $the_excerpt; ?> </p> </div> </figcaption> </figure> </article> <?php } } // Restore original Post Data wp_reset_query(); return ob_get_clean(); }
function msp_the_resized_image($img_url = "", $width = null, $height = null, $crop = null, $quality = 100) { echo msp_get_the_resized_image($img_url, $width, $height, $crop, $quality); }
public function get_posts_result($args) { $slide_image_target = isset($args['image_from']) ? $args['image_from'] : 'auto'; $exclude_posts_without_image = isset($args['exclude_post_no_image']) ? $args['exclude_post_no_image'] : false; $th_wp_query = $this->get_query_results($args); ob_start(); if ($th_wp_query->have_posts()) { while ($th_wp_query->have_posts()) { $th_wp_query->the_post(); $the_excerpt = get_the_excerpt(); $excerpt_length = isset($args['excerpt_length']) ? $args['excerpt_length'] : ''; if (!empty($excerpt_length)) { $the_excerpt = msp_get_trimmed_string(get_the_excerpt(), (int) $excerpt_length); } $the_media = ''; // get featured on first image in post $the_media_src = msp_get_auto_post_thumbnail_url($th_wp_query->post->ID, $slide_image_target); if (!empty($the_media_src)) { $the_media_tag = msp_get_the_resized_image($the_media_src, 80, 80, true, 85); // skip this post if if (empty($the_media_tag) && $exclude_posts_without_image) { continue; } $the_media = sprintf('<div class="msp-entry-media" ><a href="%s" target="_blank">%s</a></div>', get_the_permalink(), $the_media_tag); // exclude posts without image } elseif ($exclude_posts_without_image) { continue; } ?> <article class="msp-post msp-post-<?php echo $th_wp_query->post->ID; ?> msp-post-<?php echo $th_wp_query->post->post_type; ?> "> <figure> <?php echo $the_media; ?> <figcaption> <div class="msp-entry-header"> <h4 class="msp-entry-title"><a href="<?php the_permalink(); ?> " target="_blank"><?php the_title(); ?> </a></h4> </div> <div class="msp-entry-content"> <time datetime="<?php the_time('Y-m-d'); ?> " title="<?php the_time('Y-m-d'); ?> " ><?php the_time('F j, Y'); ?> </time> ( <span class="ps-post-id">Post ID: <?php the_ID(); ?> </span> ) <p><?php echo $the_excerpt; ?> </p> </div> </figcaption> </figure> </article> <?php } } // Restore original Post Data wp_reset_query(); return ob_get_clean(); }