在您的功能中。php
function show_all_thumbs() {
global $post;
$post = get_post($post);
$images =& get_children( \'post_type=attachment&post_mime_type=image&output=ARRAY_N&orderby=menu_order&order=ASC&post_parent=\'.$post->post_parent);
if($images) {
foreach( $images as $imageID => $imagePost ){
unset($the_b_img);
$the_b_img = wp_get_attachment_image($imageID, \'thumbnail\', false);
$thumblist .= \'<a href="\'.get_attachment_link($imageID).\'">\'.$the_b_img.\'</a>\';
}
}
return $thumblist;
}
在页面模板文件中:
$loop = new WP_Query(
array(
\'post_type\' => \'demo\', // or whatever is called your custom post type
\'cat\' => 5, // or whatever is the "id" for your custom post type category
\'posts_per_page\' => 10
)
);
if ( $loop->have_posts() ) :
while ( $loop->have_posts() ) : $loop->the_post();
echo show_all_thumbs();
endwhile;
endif;
请告诉我们。
对于与本主题无关的不同/额外问题,请分别提问,开始新的问题线程。
Example for Featured Image version:
$loop = new WP_Query(
array(
\'post_type\' => \'demo\', // or whatever is called your custom post type
\'cat\' => 5, // or whatever is the "id" for your custom post type category
\'posts_per_page\' => 10
)
);
if ( $loop->have_posts() ) :
while ( $loop->have_posts() ) : $loop->the_post();
if ( has_post_thumbnail() ) {
the_post_thumbnail();
}
endwhile;
endif;