WordPress.org

Ready to get started?Download WordPress

Forums

Page-list
[resolved] Displaying thumbnails instead of a list (2 posts)

  1. Luciob89
    Member
    Posted 2 years ago #

    I want to show the thumbnail of the subpages of a specific page. I currently have:

    <?php
    $children = wp_list_pages('title_li=&child_of=32&echo=0');
    if ($children) { ?>
    
    <?php echo $children; ?>
    <?php } ?>

    which only displays a list. How can I display the thumbnails?

    http://wordpress.org/extend/plugins/page-list/

  2. webvitaly
    Member
    Plugin Author

    Posted 2 years ago #

    You should create your list of pages manually and without wp_list_pages():

    <?php
    $page_list_ext_args = array(
    	'show_image' => $show_image,
    	'show_title' => $show_title,
    	'show_content' => $show_content,
    	'limit_content' => $limit_content,
    	'image_width' => $image_width,
    	'image_height' => $image_height,
    	'child_of' => pagelist_norm_params($child_of),
    	'sort_order' => $sort_order,
    	'sort_column' => $sort_column,
    	'hierarchical' => $hierarchical,
    	'exclude' => pagelist_norm_params($exclude),
    	'include' => $include,
    	'meta_key'     => $meta_key,
    	'meta_value'   => $meta_value,
    	'authors' => $authors,
    	'parent' => pagelist_norm_params($parent),
    	'exclude_tree' => $exclude_tree,
    	'number' => '', // $number - own counter
    	'offset' => 0, // $offset - own offset
    	'post_type' => $post_type,
    	'post_status' => $post_status,
    	'class' => $class,
    	'strip_tags' => $strip_tags,
    	'strip_shortcodes' => $strip_shortcodes,
    	'more_tag' => $more_tag,
    	'show_child_count' => $show_child_count,
    	'child_count_template' => $child_count_template,
    	'show_meta_key' => $show_meta_key,
    	'meta_template' => $meta_template
    );
    $list_pages = get_pages( $page_list_ext_args );
    foreach($list_pages as $page){
    	if (function_exists('get_the_post_thumbnail')) {
    		if( get_the_post_thumbnail($page->ID) ){
    			$list_pages_html .= '<div><a href="'.$link.'" title="'.esc_attr($page->post_title).'">';
    			$list_pages_html .= get_the_post_thumbnail($page->ID, array($image_width,$image_height));
    			$list_pages_html .= '</a></div> ';
    		}
    	}
    	$list_pages_html .= '<h3><a href="'.$link.'" title="'.esc_attr($page->post_title).'">'.esc_attr($page->post_title).'</a></h3>';
    }
    $list_pages_html .= '<div>'."\n".$list_pages_html."\n".'</div>';
    echo $list_pages_html;

    Simmilar code you may find in source code of the Page-List plugin.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags