2016-07-25 4 views
0

다른 페이지의 ID를 가져와 표시 슬라이더를 표시하는 단축 코드 슬라이더를 만들었습니다. Shordcode 잘 작동하지만 문제는 내가 과거 shortcode 여러 번 같은 페이지/템플릿 페이지에서 첫 번째 하나만 보여줍니다 복사 할 때마다. 이 문제는 내가 동일한 shortcode 유형을 지난 경우에만 발생하지만 같은 페이지의 다른 shortcode를 지나치면 잘 작동합니다. 여기 WP 여러 페이지가 같은 페이지 또는 템플릿 페이지에서 작동하지 않습니다.

는 라이브 예를 http://objextheme.wpengine.com/

이 하나 하시다을 볼 수 있습니다 단축 코드 여기

[objectx-pages-list id="15,16,17"] 
[objectx-pages-list ids="25,26,27"] 

여기에 내 코드

add_shortcode('objectx-pages-list', 'objectx_pages_list_func'); 
function objectx_pages_list_func($atts) { 
global $post; 
ob_start(); 
extract(shortcode_atts(array('ids' => '1186'), $atts)); 
$id_array = explode(',', $ids); 
$pages_query = new WP_Query(array(
    'post_type' => 'page', 
    'post__in' => $id_array, 
    'order' => 'ASC', 
    'orderby' => 'title', 
)); 
if ($pages_query->have_posts()) { ?> 
<div class="carousel-wrapper"> 
<div class="owl-carousel owl-theme carousel-1" id="carousel-rooms"> 
<?php while ($pages_query->have_posts()) : $pages_query->the_post(); 
$featured_image = wp_get_attachment_url(get_post_thumbnail_id($post->ID)); 
?> 
<div <?php post_class('item'); ?> id="post-<?php the_ID(); ?>"> 
    <div class="row"> 
     <div class="col-md-7"> 
      <div class="img-rooms"> 
       <a href="<?php the_permalink(); ?>"> 
       <img class="img-responsive wp-post-image" src="<?php echo $featured_image; ?>"></a> 
      </div> 
     </div> 
    <div class="col-md-5"> 
     <div class="detail-rooms"> 
      <h2 class="title-room "><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> 
      <?php the_excerpt(); ?> 
     </div> 
    </div> 
    </div> 
</div> 
<?php endwhile; ?> 
</div> 
</div> 
<?php $myvariable_pages = ob_get_clean(); 
wp_reset_postdata(); 
return $myvariable_pages; 
    } 
} 

입니다 잘 옥상 PATIO & 라운지 을 rking 그러나 이것은 내가 실수를하고있는 중이 야 어디 나를 인도 해주십시오 버티고 스카이 라운지

에서 이 주를 작동하지 않습니다. 감사합니다

다음

답변

0
add_shortcode('objectx-pages-list', 'objectx_pages_list_func'); 
function objectx_pages_list_func($atts) { 
global $post; 
ob_start(); 
extract(shortcode_atts(array('ids' => '1186'), $atts)); 
$id_array = explode(',', $ids); 
$pages_query = new WP_Query(array(
    'post_type' => 'page', 
    'post__in' => $id_array, 
    'order' => 'ASC', 
    'orderby' => 'title', 
)); 
if ($pages_query->have_posts()) { ?> 
<div class="carousel-wrapper"> 
<div class="owl-carousel owl-theme carousel-1" id="carousel-rooms"> 
<?php while ($pages_query->have_posts()) : $pages_query->the_post(); 
$featured_image = wp_get_attachment_url(get_post_thumbnail_id($post->ID)); 
?> 
<div <?php post_class('item'); ?> id="post-<?php the_ID(); ?>"> 
    <div class="row"> 
     <div class="col-md-7"> 
      <div class="img-rooms"> 
       <a href="<?php the_permalink(); ?>"> 
       <img class="img-responsive wp-post-image" src="<?php echo $featured_image; ?>"></a> 
      </div> 
     </div> 
    <div class="col-md-5"> 
     <div class="detail-rooms"> 
      <h2 class="title-room "><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> 
      <?php the_excerpt(); ?> 
     </div> 
    </div> 
    </div> 
</div> 
<?php endwhile; ?> 
</div> 
</div> 
<?php $myvariable_pages = ob_get_clean(); 
wp_reset_postdata(); 
return $myvariable_pages; 
    } 
} 

내가 눈치 오류입니다. id = "캐 러셀 룸" 이드는 같은 페이지에서 을 반복합니다. 그것이 한 번만 완벽하게 실행되는 이유입니다.