1
1
17392018-01-29 21:11:24
JavaScript
1739, 2018-01-29 21:11:24

WordPress. How to display sub-pages of child page?

Task: when hovering over the name of a page (which is a child of another page), display a list of its sub-pages (example in the picture). 5a6f62e012d97272087604.png
Site test06.menchasha.ru .

To display child pages (without hover yet) I try this code, but it also displays parent pages:

<?php 
  $args = array(
      'child_of' => $post->ID,
      'post_type' => 'page',
      'post_status' => 'publish',
      'sort_column' => 'menu_order' 
       ); 
  $pages = get_pages($args);  ?>
  <ul> 
  <?php foreach( $pages as $page ) { ?>
   <li>
      <a href="<?php echo  get_permalink($page->ID); ?>" rel="bookmark" title="<?php echo $page->post_title; ?>">
      <span class="title1"><?php echo $page->post_title; ?></span>
      </a>
  </li>
  <?php } ?>
  </ul>


Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mike, 2018-01-30
@1739

Use walkers.
Judging by the site, there is a 3rd bootstrap, here is a repository with a branch for the 3rd version.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question