WordPress.org

Ready to get started?Download WordPress

Forums

List pages with attached image (1 post)

  1. janvdm
    Member
    Posted 3 years ago #

    Hello,

    I'm trying to create a simple image based page navigation that consists out of

    - the page title
    - the image attached to the page

    and that looped for all the children of a page.

    But I just can't figure it out.

    What I have so far is:

    <?php
    echo '
    <ul>';
    // Get a list of pages
    $children = get_children('post_type=page&post_parent=26');
    
    // Loop over each page
    foreach ($children as $child) {
    // Get the attached image url
    $thumbnail = wp_get_attachment_url($post->ID);
    // Print to screen
    echo '<li class="page_item page-item-'. $child->ID .'"><a>ID .'" href="?page_id='. $child->ID .'"><img src="'. $thumbnail .'">'. $child->post_title .'</a>';
    }
    echo '</ul>
    ';
    
    ?>

    Anybody any thoughts?

Topic Closed

This topic has been closed to new replies.

About this Topic