how can i display children of my parent page in one of the children page (wordpress)

I'm looking for how display the children pages of a parent page IN THE CHILDREN i can display all the children only

I'm looking for how display the children pages of a parent page IN THE CHILDREN

i can display all the children only in the parent page like this

<?php 
 $args = array(
    'post_type'      => 'page', //write slug of post type
    'posts_per_page' => -1,
    'post_parent'    => $post->ID,
    'order'          => 'ASC',
    'orderby'        => 'menu_order'
 );

 $childrens = new WP_Query( $args );
 if ( $childrens->have_posts() ) : ?>
 <?php while ( $childrens->have_posts() ) : $childrens->the_post(); ?>

 <!-- child <?php the_ID(); ?> -->
 <div class="grid-item grid-50" style="padding: 20px;">

 <?php  if ( $post->post_content=="" ) { ?> 
 <!-- IF NO CONTENT -->

  <?php if ( has_post_thumbnail() ) { ?>
  <!-- THUMBNAIL SEUL SANS LIEN -->
  <?php echo get_the_post_thumbnail( $page->ID, 'full-size' ); ?>
  <?php edit_post_link('(add content?)', '<p>', '</p>', null, 'editaddclass'); ?> 

    <?php } else { ?>
    <!-- BLOC VIDE -->
    <div class="" style="padding: 20px; text-align: center; border: 1px dotted grey;">
    CE BLOC EST VIDE<br>
    <?php edit_post_link('(le supprimer / add content)', '<p>', '</p>', null, 'editaddclass'); ?>
    </div>
    <?php } ?> 

    <!-- OR WHIT CONTENT -->       
    <?php } else { ?>

      <!-- SI LE CONTENU -->
      <div class="">

        <?php if ( has_post_thumbnail() ) { ?>
        <!-- THUMBNAIL AVEC CONTENT & LINK -->

        <a href="<?php the_permalink(); ?>">
        <div><?php echo get_the_post_thumbnail( $page->ID, 'principal' ); ?></div>
        <div style="width: 100%; text-align: center; padding:10px"><?php the_title(); ?></div>
        <?php edit_post_link('(modifier)', '<p>', '</p>', null, 'editaddclass'); ?>
        </a>

          <?php } else { ?>
          <!-- IL Y A DU CONTENU MAIS PAS DE THUBNAIL -->
          <div class="" style="padding: 70px 20px; text-align: center; background-color: #eee">
          THUMBNAIL MANQUANTE<br>
          </div>
          <div style="width: 100%; text-align: center; padding:10px">
            <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
          </div>
          <?php edit_post_link('(ajouter en une / modifier)', '<p>', '</p>', null, 'editaddclass'); ?>

        <?php } ?>

      </div>
      <!-- /if le content -->

 <?php }; ?>

 </div>
 <!-- /child <?php the_ID(); ?> -->
 <?php endwhile; endif; wp_reset_query(); ?>

</div>
</div>
<!-- /CHILDREN --> 

can't find how to display it also at the the end of every children

do you follow me ? :)

I'm looking for how display the children pages of a parent page IN THE CHILDREN

i can display all the children only in the parent page like this

<?php 
 $args = array(
    'post_type'      => 'page', //write slug of post type
    'posts_per_page' => -1,
    'post_parent'    => $post->ID,
    'order'          => 'ASC',
    'orderby'        => 'menu_order'
 );

 $childrens = new WP_Query( $args );
 if ( $childrens->have_posts() ) : ?>
 <?php while ( $childrens->have_posts() ) : $childrens->the_post(); ?>

 <!-- child <?php the_ID(); ?> -->
 <div class="grid-item grid-50" style="padding: 20px;">

 <?php  if ( $post->post_content=="" ) { ?> 
 <!-- IF NO CONTENT -->

  <?php if ( has_post_thumbnail() ) { ?>
  <!-- THUMBNAIL SEUL SANS LIEN -->
  <?php echo get_the_post_thumbnail( $page->ID, 'full-size' ); ?>
  <?php edit_post_link('(add content?)', '<p>', '</p>', null, 'editaddclass'); ?> 

    <?php } else { ?>
    <!-- BLOC VIDE -->
    <div class="" style="padding: 20px; text-align: center; border: 1px dotted grey;">
    CE BLOC EST VIDE<br>
    <?php edit_post_link('(le supprimer / add content)', '<p>', '</p>', null, 'editaddclass'); ?>
    </div>
    <?php } ?> 

    <!-- OR WHIT CONTENT -->       
    <?php } else { ?>

      <!-- SI LE CONTENU -->
      <div class="">

        <?php if ( has_post_thumbnail() ) { ?>
        <!-- THUMBNAIL AVEC CONTENT & LINK -->

        <a href="<?php the_permalink(); ?>">
        <div><?php echo get_the_post_thumbnail( $page->ID, 'principal' ); ?></div>
        <div style="width: 100%; text-align: center; padding:10px"><?php the_title(); ?></div>
        <?php edit_post_link('(modifier)', '<p>', '</p>', null, 'editaddclass'); ?>
        </a>

          <?php } else { ?>
          <!-- IL Y A DU CONTENU MAIS PAS DE THUBNAIL -->
          <div class="" style="padding: 70px 20px; text-align: center; background-color: #eee">
          THUMBNAIL MANQUANTE<br>
          </div>
          <div style="width: 100%; text-align: center; padding:10px">
            <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
          </div>
          <?php edit_post_link('(ajouter en une / modifier)', '<p>', '</p>', null, 'editaddclass'); ?>

        <?php } ?>

      </div>
      <!-- /if le content -->

 <?php }; ?>

 </div>
 <!-- /child <?php the_ID(); ?> -->
 <?php endwhile; endif; wp_reset_query(); ?>

</div>
</div>
<!-- /CHILDREN --> 

can't find how to display it also at the the end of every children

do you follow me ? :)

Share Improve this question edited Jun 19, 2019 at 1:29 fuxia 107k39 gold badges255 silver badges459 bronze badges asked Jun 19, 2019 at 0:19 Quentin ContentQuentin Content 33 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

if you want to display all child pages of parent page in the child page then you can try this. it will display child page title and its links.

$current_page_id = get_the_id();
    $parent_id = wp_get_post_parent_id( $current_page_id );
    if(!empty($parent_id))
    {
        $child_args = array(
            'post_type'      => 'page',
            'posts_per_page' => -1,
            'post_parent'    => $parent_id,
            'post_status'    => 'publish',
            'order'          => 'ASC',
            'orderby'        => 'menu_order'
             );
        $parent = new WP_Query( $child_args );

        if ( $parent->have_posts() ) : 
        echo '<div class="single-sidebar">';
        echo '<ul>';
             while ( $parent->have_posts() ) : $parent->the_post();
                $addclass  = "";
                if($current_page_id == get_the_ID())
                {
                    $addclass  = "active";
                }
              ?>                        
                <li class="<?php echo $addclass; ?>"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
                <?php 
            endwhile; 

            echo '</ul>';
            echo '</div>';
         endif; 
            wp_reset_postdata(); 
    }

let me know if this helps you

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745389507a4625596.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信