wordpress - WP Query Multiple Shortcodes not working on same page or template page -
i created shortcode slider gets ids of different pages , show display slider. shordcode works fine issue whenever copy past shortcode multiple times on same page/ template page shows first one. issue occurs only when past same type of shortcode if past other shortcode on same page works fine.
here code
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; } }
here shortcode
[objectx-pages-list id="15,16,17"] [objectx-pages-list ids="25,26,27"]
here can see live example http://objextheme.wpengine.com/
this 1 working fine rooftop patio & lounge not working this week @ vertigo sky lounge
please guide me doing mistake. thanks
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; } }
here error noticed. id="carousel-rooms" id repeating on same page. why 1 time runs perfect.
Comments
Post a Comment