• Hi, I’m Paolo from Italy and I’m a newbie on WordPress.

    I need suggestions about how to proceed to get a list of sub-pages displayed in a particular html structure, not only as list elements you can get using the wp_list_pages.

    I’ve got the following scenario:

    top-Page
    – sub-page 1
    – sub-page 2
    – sub-page 3
    … etc

    I need to create a sort of index menu of each sub-page as follow

    • <img src=”sub-page 1 image”/>
      <div>
      <h3>Sub-page 1 Title</h3>
      <p>Sub-page 1 Custom-field text
      Enter?</p>
      </div>
    • <img src=”sub-page 2 image”/>
      <div>
      <h3>Sub-page 2 Title</h3>
      <p>Sub-page 2 Custom-field text
      Enter?</p>
      </div>
    • <img src=”sub-page 3 image”/>
      <div>
      <h3>Sub-page 3 Title</h3>
      <p>Sub-page 3 Custom-field text
      Enter?</p>
      </div>
    • … etc

    In other words, I’d like to create a sort of foreach cycle (?) into a

      list, that update each time I will add a new sub-page to that top-page.

    …pardon my english and my knowledge… ??

    Ciao
    Paolo

Viewing 1 replies (of 1 total)
  • <?php
    echo the_title();
    
    $id = get_the_ID();
    
    if ( is_page() )
    {
      $pages = get_pages('sort_column=menu_order&title_li=&
      child_of='.$id.'&depth=1');
    
      echo '<ul>';
      foreach($pages as $page)
      {
        $post_thumbnail_id = get_post_thumbnail_id($page->ID);
        if($post_thumbnail_id)
        {
          $attach_image = wp_get_attachment_image($post_thumbnail_id,
          array($width, $height), true );
        } else {
          $attach_image = '';
        }
    
        echo '<li>';
        echo $attach_image;
        echo '<div>';
        echo '<h3>'.$page->post_title.'</h3>';
        echo '<p>'.$page->meta_key.'</p>';
        echo '</li>';
      }
      echo '</ul>';
    }
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Page list customization’ is closed to new replies.