• dileepraja

    (@dileepraja)


    hi
    this is my shortcode function but when i am using this shortcode for other parent pages previous sub pages only displaying please check my code if any thing wrong tell me advance in thank you

    function shortcode_parent(){
      $args = array('post_type' => 'vh_accommodation', 'orderby' => 'title', 'order' => 'ASC', 'post_parent' => 0, 'posts_per_page'=>'-1');
      $the_query1 = new WP_Query($args);
     echo '<h2 style="background: none repeat scroll 0 0 #dba63f; color: #fff; font-family: Open Sans; font-size: 18px; margin-bottom: 15px; margin-top: 0 !important; padding: 10px; border-bottom: 2px solid #c18c25;">';
     echo "Rooms Available";
     echo '</h2>';  
    
     if($the_query1->have_posts()){
      while ($the_query1->have_posts()) {
        $the_query1->the_post();
        global $thisPost;
        $thisPost=get_the_ID();
        //echo $thisPost;
    
     $inner_args = array('post_type' => 'vh_accommodation', 'post_parent' => $thisPost, 'posts_per_page' => 5,'orderby' => 'title', 'order' => 'ASC',);
     $inner_query = new WP_Query($inner_args);
    
     if($inner_query->have_posts()){
      while ($inner_query->have_posts()) {
        $inner_query->the_post();
        //echo get_the_title($inner_query->post->ID);
        //echo the_title();
        ?>
          <div class="col-md-6" style="padding-left:0;padding-right:0;">
          <div class="room_img1 image-panel" style="margin-bottom:25px;padding:15px;">
              <?php  if(has_post_thumbnail()) ?>
              <?php echo the_post_thumbnail(array(350,250));?>
               <img src="<?php echo get_template_directory_uri().'/images/6.jpg'?>" style="width:350px;height:250px;"> 
    
                <p class="text-center page-heading"><?php the_title();?></p>
                <p><?php the_excerpt();?></p>
                <?php if(get_post_meta(get_the_ID(),'room_size',true) || get_post_meta(get_the_ID(),'room_bed',true) || get_post_meta(get_the_ID(),'max_person',true))?>
                <p class="room_exrt"><?php if(get_post_meta(get_the_ID(),'max_person',true)){?><div class="room_exrt"><span class="r-title text-center" style="padding-left:118px;"><?php _e('Max person : '); ?></span><?php $person=get_post_meta(get_the_ID(),'max_person',true); echo "";for($i=1;$i<=$person;$i++){echo "<span class='icon-male'></span>";}?></div><?php }?></span>
                <span class="room_exrt"><?php if(get_post_meta(get_the_ID(),'room_bed',true)){?><span><span class="r-title" style="padding-left:118px;"><?php _e('Beds : ');?></span><?php echo get_post_meta(get_the_ID(),'room_bed',true);?></span><?php }?></p>
                <p class="room_exrt"><?php if(get_post_meta(get_the_ID(),'room_size',true)){?><span><?php echo get_post_meta(get_the_ID(),'room_size',true);?></span><?php }?></p>
                <p class="text-center" style="padding-top:5px;"><span class="icon-food"></span>?<span class="icon-desktop"></span>?<span class="icon-glass"></span>?<span class="icon-globe"></span>?<span class="icon-credit-card"></span></p>
                <p class="text-center"><a>" style="color:#D4B66D !important;text-decoration:none;">Read More</a></p>
    
                </br/>
    
            </div>
            </div>
        <?php
      }
     }
     }
     }
     wp_reset_postdata();
    }

  • The topic ‘child pages not displaying’ is closed to new replies.