我有一个自定义的帖子类型设置,如下所示:
add_action(\'init\', \'portfolio_register\');
function portfolio_register() {
$labels = array(
\'name\' => _x(\'Photos\', \'post type general name\'),
\'singular_name\' => _x(\'Portfolio Item\', \'post type singular name\'),
\'add_new\' => _x(\'Add New\', \'portfolio item\'),
\'add_new_item\' => __(\'Add New Portfolio Item\'),
\'edit_item\' => __(\'Edit Portfolio Item\'),
\'new_item\' => __(\'New Portfolio Item\'),
\'view_item\' => __(\'View Portfolio Item\'),
\'search_items\' => __(\'Search Portfolio\'),
\'not_found\' => __(\'Nothing found\'),
\'not_found_in_trash\' => __(\'Nothing found in Trash\'),
\'parent_item_colon\' => \'\'
);
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'query_var\' => true,
//\'menu_icon\' => get_stylesheet_directory_uri() . \'/article16.png\',
\'rewrite\' => true,
\'capability_type\' => \'post\',
\'hierarchical\' => false,
\'menu_position\' => 4,
\'taxonomies\' => array(\'post_tag\',\'category\'),
\'supports\' => array(\'title\',\'editor\',\'comments\',\'trackbacks\',\'revisions\',\'custom-fields\',\'page-attributes\',\'thumbnail\', \'excerpt\', \'tags\')
);
它把所有的元框都拉了进来,单页的一切都很好。
在主页上,我从特色类别中查询如下:
根据斯巴达克斯的建议进行编辑
<?php
$args = array(\'category_name\' => \'featured\',
\'post_type\' => array (\'post\',\'Photos\'),
\'posts_per_page\' => 20);
$the_query = new WP_Query($args);
while ($the_query->have_posts()) : $the_query->the_post();?>
<?php //getImage(1); ?>
<div class="featuredSlide">
<a href="<?php the_permalink(); ?>">
<img src="<?php bloginfo(\'template_url\'); ?>/scripts/timthumb.php?src=<?php echo get_first_attachment() ?>&w=500&h=500&a=b&zc=1&q=80" alt="<?php the_title(); ?>" /></a>
<?php the_title(); ?>
</div>
<?php endwhile; ?>
这对我写的普通帖子很好,但自定义帖子类型类别中的帖子都不会被拉入这个特色类别查询。有人能看到哪里出了问题,或者对我应该寻找什么有什么建议吗?