Created
December 15, 2016 20:16
-
-
Save Maden-maxi/6e0b270acc28c42104cc007814a0ade7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function comments_all_func( $atts ){ | |
extract( shortcode_atts( array( | |
'category' => '' | |
), $atts ) ); | |
$categories = explode( ',', $atts['category'] ); | |
$taxq = array( | |
#'posts_per_page' => 6, | |
'post_type' => 'wpm-testimonial', | |
'post_status' => 'publish', | |
'tax_query' => array( | |
array( | |
'taxonomy' => 'wpm-testimonial-category', | |
'field' => ( is_string($category) ) ? 'slug' : 'id', | |
'terms' => $categories | |
), | |
), | |
); | |
$query = new WP_Query($taxq); | |
$count_on_page = 3; | |
$quantity_posts = count($query->posts); | |
ob_start(); | |
echo "<pre>"; | |
var_dump($query); | |
echo "</pre>"; | |
// Цикл | |
if ( $query->have_posts() ) : | |
?> | |
<div id="carousel-review" class="carousel slide hidden-xs hidden-sm cr1 wow fadeInRightBig" data-ride="carousel" data-wow-duration="2s"> | |
<div class="carousel-main"> | |
<div class="carousel-inner" role="listbox"> | |
<?php | |
$i=0; | |
while ( $query->have_posts() ) : | |
$query->the_post(); | |
$content = strip_tags( get_the_content() ); | |
$age = get_metadata( 'post', get_the_ID(), 'age', true ); | |
$company = get_metadata( 'post', get_the_ID(), 'company_name', true ); | |
$i++; | |
$mod = $i % $count_on_page; | |
if ($mod == 1 && $i==1): | |
?> | |
<div class="item active"> | |
<div class="tooltip-container"> | |
<?php elseif( $mod == 1 && $i!=1 ): ?> | |
<div class="item"> | |
<div class="tooltip-container"> | |
<?php endif; ?> | |
<div class="rezen-wrapper col-md-4"> | |
<div class="first"> | |
<div class="main-tooltip"> | |
<p class="review-text-full"><?= $content; ?></p> | |
<p class="date"><?php the_date(); ?></p> | |
<a href="#" class="mehr">Mehr</a> | |
</div> | |
<h3><?php echo get_the_author() . ', ' . $age . ', ' . $company; ?></h3> | |
</div> | |
</div> | |
<?php if (($mod == 0) || ($i == $quantity_posts )):?> | |
</div> | |
</div> | |
<?php endif; | |
endwhile; | |
?> | |
</div> | |
<a class="left carousel-control" href="#carousel-review" data-slide="prev"> | |
<img src="/wp-content/themes/mrt-theme/images/arrow-gray-left.png" alt="arrow-left" /> | |
</a> | |
<a class="right carousel-control" href="#carousel-review" data-slide="next"> | |
<img src="/wp-content/themes/mrt-theme/images/arrow-gray-right.png" alt="arrow-right" /> | |
</a> | |
</div> | |
</div> | |
<?php endif; | |
/* Возвращаем оригинальные данные поста. Сбрасываем $post. */ | |
wp_reset_postdata(); | |
$output = ob_get_contents(); | |
ob_end_clean(); | |
return $output; | |
} | |
add_shortcode('comments_all','comments_all_func'); | |
#[comments_slider category=''] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment