Here is my 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() ) { ?>
<?php while ( $pages_query->have_posts() ) : $pages_query->the_post();
$featured_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
?>
id=”post-<?php the_ID(); ?>”>
<h2 class=”title-room “>
“><?php the_title(); ?></h2>
<?php the_excerpt(); ?>
<!–<h2 class=”title-list collapse”>VIP INCLUDES</h2>–>
<?php endwhile; ?>
<?php $myvariable_pages = ob_get_clean();
wp_reset_postdata();
return $myvariable_pages;
}
}
/Whenever i call shortcode two times on same page or template only first code works others not working from this query but if i past other query shortcode it works fine./
Here is my shortcode.
[‘objectx-pages-list’]