• I’m using this code to post the child pages of the said ID but basically I want to convert this dynamically by using the_ID but when I use the_ID it posts all of the pages and posts. Doing the <?php echo the_ID(); ?> display the current ID. Not quite sure on how can I used this to control the loop.

    123 is the ID of the Parent this needs to be converted to the_ID().

    <?php
    			$args = array(
    			    'post_type' => 'page',
    			    'post_status' => 'publish',
    			    'posts_per_page' => -1,
    			    'post_parent' => 123,
    			    'orderby'=> 'menu_order',
    			    'order'=> 'asc',
    			);
    			$query = new WP_Query($args);
    			$catNull = get_template_directory_uri();
    			echo '<ul class="all-service">';
    			while ($query->have_posts()) {
    			    $query->the_post(); ?>
    				<li class="all-service-item">
    					<a href="<?php the_permalink(); ?>">
    					<div class="content">
    						<h4><?php the_title(); ?></h4>
    						<?php the_content(); ?>
    					</div></a>
    				</li>
    			    <?php
    			}
    			wp_reset_postdata();?>
    			</ul>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘post child contents by using current id’ is closed to new replies.