function shortcode_testimonials($atts, $content = null, $code) { extract(shortcode_atts(array('style' => '1', 'type' => 'grid', 'items_per_column' => 3, 'number_of_posts' => 5, 'image_width' => 50, 'image_height' => 50, 'background_color' => 'F7F7F7'), $atts)); global $post; $i = 1; $args = array('posts_per_page' => $number_of_posts, 'post_status' => 'publish', 'post_type' => 'testimonial'); $testimonial_array = get_posts($args); $testimonial_count = count($testimonial_array); $output = ''; if ($testimonial_count > 0) { $output .= '<div class="testimonials-container">'; if ($type == "slider") { if ($testimonial_count > $items_per_column) { $output .= '<div id="' . $items_per_column . '_testimonial_carousel" class="testimonial-carousel">'; } else { $output .= '<div id="testimonial_grid" class="testimonial-grid testimonial-cols-' . $items_per_column . '">'; } } else { if ($type == "grid") { $output .= '<div id="testimonial_grid" class="testimonial-grid testimonial-cols-' . $items_per_column . '">'; } else { if ($type == "list") { $output .= '<div id="testimonial_list" class="testimonial-list">'; } } } $i = 1; foreach ($testimonial_array as $post) { setup_postdata($post); get_post_meta($post->ID, 'testimonial_position', TRUE) ? $testimonial_position = get_post_meta($post->ID, 'testimonial_position', TRUE) : ($testimonial_position = ''); get_post_meta($post->ID, 'testimonial_link', TRUE) ? $testimonial_link = get_post_meta($post->ID, 'testimonial_link', TRUE) : ($testimonial_link = ''); $contents = strip_tags(templatemela_strip_images($post->post_content)); if ($i % $items_per_column == 1) { $class = " first-item"; } elseif ($i % $items_per_column == 0) { $class = " last-item"; } else { $class = ""; } $output .= '<div class="item' . $class . '"><div class="product-block">'; $output .= '<div class="single-testimonial">'; $output .= '<div class="testimonial-content">'; $output .= '<div class="testimonial-top" style="' . $background_color . '"><blockquote><q>' . substr($contents, 0, 150) . '</q></blockquote></div>'; $output .= '<div class="testimonial-bottom"></div>'; $output .= '</div>'; $output .= '<div class="testmonial-other">'; $output .= '<div class="testmonial-image">'; if (has_post_thumbnail() && !post_password_required()) { $post_thumbnail_id = get_post_thumbnail_id(); $post_thumbnail_url = wp_get_attachment_url($post_thumbnail_id); $output .= '<img src="' . mr_image_resize($post_thumbnail_url, $image_width, $image_height, true, 'left', false) . '" title="' . get_the_title() . '" alt="' . get_the_title() . '" />'; } else { $output .= '<i style="width:' . $image_width . ';height:' . $image_height . ';" class="fa fa-user"></i>'; } $output .= '</div>'; $output .= '<div class="testmonial-text">'; $output .= '<div class="testimonial-title">' . get_the_title() . '</div>'; if (!empty($testimonial_position)) { if (!empty($testimonial_link)) { $output .= '<div class="testimonial-email"><a target="_Blank" title="' . $testimonial_position . '" href="' . $testimonial_link . '" >' . $testimonial_position . '</a></div>'; } else { $output .= '<div class="testimonial-email">' . $testimonial_position . '</div>'; } } $output .= '</div>'; $output .= '</div>'; $output .= '</div>'; $output .= '</div></div>'; $i++; } $output .= '</div>'; $output .= '</div>'; } else { $output .= '<div class="no-result">No results found...</div>'; } wp_reset_query(); return $output; }
function templatemela_portfolio_excerpt($limit) { $contents = substr(templatemela_strip_images(strip_tags(get_the_excerpt())), 0, $limit); $excerpt = $contents; if (strlen($contents) >= $limit) { $excerpt .= '…'; } return $excerpt; }