Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter tlucht

    (@tlucht)

    Sub navigation

    Thread Starter tlucht

    (@tlucht)

    I know I’m close with the ‘orderby’, but I can’t seem to figure this out!

    Thread Starter tlucht

    (@tlucht)

    <?php
    global $post;
    
    $children = get_children( array(
      'post_parent' => $post->ID,
      'post_type' => 'page',
      'numberposts' => -1
    ));
    
    // if current page has children set parent to current page
    if ( count($children) > 0 ) {
    
      $id = $post->ID;
    
    // if current page doesn't have children use parent of current page
    } else {
    
      $parents = get_post_ancestors( $post->ID );
    
      if ( count($parents) > 0 ) {
        $id = $parents[0];
      }
    }
    
    if ( isset($id) ):
    
      $the_query = new WP_Query(array(
        'post_type' => 'page',
        'posts_per_page' => -1,
        'post_parent' => $id,
        'order' => 'ASC',
        'orderby' => 'menu_order'
      ));
    
      if ( $the_query->have_posts() ) : ?>
    
        <h3><a href="<?php echo get_the_permalink( $id ); ?>"><?php echo get_the_title( $id ); ?></a></h3>
    
        <ul class="nav nav-pills nav-stacked">
    
        <?php while ( $the_query->have_posts() ) :  $the_query->the_post(); ?>
    
          <li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
    
        <?php endwhile; ?>
    
        </ul>
    
      <?php endif;
    
    endif; ?>
    

    That’s the menu php page.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Beyond widget side menu editing, with the php page, custom template.’ is closed to new replies.