같은 페이지에 단편을 두 번 추가하려하지만 두 번째 단락이 아무 것도 표시하지 않는 것이 문제입니다. 나는 이것이 쿼리에 문제가 될 수 있다고 생각하지만, 이것에 대해서는 확실하지 않다. 내 짧은 코드는 다음과 같습니다.동일한 페이지에서 두 번 단축 코드 Wordpress
<?php
defined('ABSPATH') or die('No script kiddies please!');
if (! is_admin()) {
require_once(ABSPATH . 'wp-admin/includes/post.php');
}
function eleva_shortcode($atts = array()){
$atts=shortcode_atts(array(
'display' => '3',
'limit' => '5',
'length' => '15',
'title' => "",
'category' => ""
), $atts) ;
$display = $atts['display'] ;
$pars = intval($display);
$col = 0;
if($pars==1 || $pars==2 || $pars==3 || $pars==4 || $pars==6){
$col = 12/$pars;
}
else{
$pars =3;
$col = 12/$pars;
}
$limit = $atts['limit'];
$pars_limit = intval($limit);
$length = $atts['length'];
$pars_length = intval($length);
$title = $atts['title'];
$id = post_exists($title);
$taxonomy = $atts['category'];
?>
<script>
var tQ = jQuery.noConflict();
tQ(document).ready(function(){
if (tQ(window).width() > 992) {
var testimonialItem = tQ('#testimonials-slider-shortcode div[class*="col-md-"]');
for(var i = 0; i < testimonialItem.length; i+=<?php echo $pars;?>) {
testimonialItem.slice(i, i+<?php echo $pars;?>).wrapAll('<div class="item"></div>');
}
} else{
var testimonialItem = tQ('#testimonials-slider-shortcode div[class*="col-md-"]');
for(var i = 0; i < testimonialItem.length; i+=1) {
testimonialItem.slice(i, i+1).wrapAll('<div class="item"></div>');
}
}
var testimonialBoxShort = 0;
tQ('#testimonials-slider-shortcode .item').each(function(){
if(tQ(this).height() > testimonialBoxShort){
testimonialBoxShort = tQ(this).height();
}
});
tQ('#testimonials-slider-shortcode .item').height(testimonialBoxShort);
tQ('#testimonials-slider-shortcode .item').first().addClass('active');
});
</script>
<div id="testimonials-slider-shortcode" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators"></ol>
<div class="carousel-inner" role="listbox">
<?php
if($id == 0 && empty($taxonomy)){
$queryT = new WP_Query(array('post_type' => 'testimonials'));
}elseif ($id == 0 && !empty($taxonomy)){
$queryT = new WP_Query(array('post_type' => 'testimonials', 'tax_query' => array(
array(
'taxonomy' => 'categorytestimonials',
'field' => 'slug',
'terms' => $taxonomy,
)))); //p is for the id;
}elseif ($id != 0 && empty($taxonomy)){
$queryT = new WP_Query(array('post_type' => 'testimonials', 'p' => $id)); //p is for the id;
}else{
$queryT = new WP_Query(array('post_type' => 'testimonials', 'p' => $id, 'tax_query' => array(
array(
'taxonomy' => 'categorytestimonials',
'field' => 'slug',
'terms' => $taxonomy,
)))); //p is for the id;)); //p is for the id;
}
if ($queryT->have_posts()) : ?>
<!-- the loop -->
<?php $count = 0;
while ($queryT->have_posts()) : $queryT->the_post(); ?>
<?php //variables
$author = get_post_meta(get_the_ID(), 'author', true);
$link = get_permalink();
?>
<?php if($count < $pars_limit || $pars_limit==0): ?>
<div class="col-md-<?php echo $col;?>">
<div class="img-wrap">
<?php if (has_post_thumbnail()) : // check if the post has a Post Thumbnail assigned to it. ?>
<a href="<?php echo $link;?>">
<?php the_post_thumbnail('full');?>
</a>
<?php else : ?>
<a href="<?php echo $link;?>">
<img alt="<?php bloginfo('name'); ?>" src="<?php echo get_template_directory_uri(); ?>/images/default.jpg">
</a>
<?php endif; ?>
</div>
<div class="info-wrap">
<p><?php echo eleva_testimonials_excerpt($pars_length +1); ?></p>
<?php // Check if the custom field has a value.
if (! empty($author)) {
echo '<span><a href="'. $link .'">'. $author . '</a></span>';
}
?>
</div>
</div>
<?php endif;
$count= $count +1;?>
<?php endwhile; ?>
<!-- end of the loop -->
<?php wp_reset_postdata(); ?>
</div>
<a class="left carousel-control" href="#testimonials-slider-shortcode" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left fa fa-angle-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#testimonials-slider-shortcode" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right fa fa-angle-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
<?php else : ?>
<p><?php _e('Sorry, no testimonials at this time'); ?></p>
<?php endif; ?>
</div>
<?php
}
add_shortcode('testimonials', 'eleva_shortcode');
?>
내가 말 루프 후 그랬어 : 위대한 작품을 –