WordPress.org

Ready to get started?Download WordPress

Forums

using wp_list_pages (4 posts)

  1. xmatter
    Member
    Posted 3 years ago #

    if i am using this code to display the child pages:

    <?php
      if($post->post_parent) {
      $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
      $titlenamer = get_the_title($post->post_parent);
      }
    
      else {
      $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
      $titlenamer = get_the_title($post->ID);
      }
      if ($children) { ?>
    
      <h2 style="text-align:center;margin:0px"> <? echo $titlenamer ?> </h2>
      <ul>
        <?php echo $children; ?>
      </ul>
    
    <?php } ?>

    how would i style the sub page title and then the sub sub page title.
    When i add a class to the ul, it carries over to all the li items.

  2. esmi
    Forum Moderator
    Posted 3 years ago #

    Use something like:

    <ul class="subpages">
        <?php echo $children; ?>
      </ul>

    Then style on .subpages and .subpages ul etc.

  3. xmatter
    Member
    Posted 3 years ago #

    hello esmi, in another forum i post, you directed me to use:

    <?php
      $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0&depth=1');
      if ($children) { ?>
    
      <ul class="subpages">
    
      <?php echo $children; ?>
    
      </ul>
      <?php } ?>

    which worked as i needed it to. from your post above, i am trying to add styling now. here is my current code:

    .subpages
    .subpages ul {}
    .subpages li {display:inline-block; margin:10px}

    my question is, is it possible to display the first sub pages with one set of styling, and then when clicked, style the sub sub page links with another style. i assume i can use something like:

    .subpages
    .subpages ul {}
    .subpages ul li {display:inline-block; margin:10px}
    .subpages ul li ul {}
    .subpages ul li ul li{}
  4. esmi
    Forum Moderator
    Posted 3 years ago #

    I'd need to see examples of these pages.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.