如果你能帮忙解决这个问题我真的很感激..我有一个模板,显示博客文章的图片库,但我想创建另一个单独的图库来显示我自定义帖子类型的图像创造了所谓的“工具包”。我可以编辑哪部分内容?
<?php /* Template Name: Top Kits */ ?>
<?php get_header(); ?>
<div id="main">
<?php do_action( 'bp_before_blog_page' ) ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2 class="post-title page-title"><?php the_title(); ?></h2>
<div class="post-content">
<?php the_content(); ?>
</div>
<?php endwhile; endif; ?>
<div class="image-gallery">
<?php
$total = $wpdb->get_var('SELECT count(p.id) FROM '.$wpdb->prefix.'posts p LEFT JOIN '.$wpdb->prefix.'postmeta pm ON p.id = pm.post_id WHERE p.post_status = \'publish\' AND post_type = \'post\' AND pm.meta_key = \'_thumbnail_id\'');
load_template( TEMPLATEPATH . '/functions/paginate.php' );
$pages = new paginate(array(
'total' => $total,
'nr_per_page' => of_get_option( 'gallery_count', 5 ) + 1
));
$thumbs = $wpdb->get_results('SELECT p.ID,p.post_title FROM '.$wpdb->prefix.'posts p LEFT JOIN '.$wpdb->prefix.'postmeta pm ON p.id = pm.post_id WHERE p.post_status = \'publish\' AND post_type = \'post\' AND pm.meta_key = \'_thumbnail_id\' ORDER BY p.post_date DESC LIMIT '.$pages->limit());
foreach ($thumbs as $thumb) : ?>
<div class="one_third">
<div class="post-img-medium">
<a href="<?php echo get_permalink($thumb->ID); ?>" rel="bookmark" title="<?php echo $thumb->post_title; ?>"><?php echo get_the_post_thumbnail($thumb->ID, 'post-medium'); ?></a>
</div>
</div>
<?php endforeach; ?>
<div class="clear"></div>
<div id="pagination">
<?php echo $pages->nav() ?>
</div>
</div>
</div><!--post-->
<?php do_action( 'bp_after_blog_page' ) ?>
</div><!--#main-->
<?php get_footer(); ?>
答案 0 :(得分:3)
使用query_posts:
<?php query_posts(array('post_type' => 'kits', 'posts_per_page' => -1 ))
if (have_posts()) : while (have_posts()) : the_post(); ?>
此处有更多信息:http://codex.wordpress.org/Function_Reference/query_posts