我的函数中有以下代码。php文件创建自定义分类法和post类型。我已经在这个帖子类型中创建了一系列帖子,并为它们附加了标签。
add_action( \'init\', \'create_my_post_types\' );
function create_my_post_types() {
register_post_type(\'portfolio\', array(
\'label\' => __(\'Portfolio\'),
\'singular_label\' => __(\'Portfolio\'),
\'public\' => false,
\'show_ui\' => true,
\'_builtin\' => false,
\'_edit_link\' => \'post.php?post=%d\',
\'capability_type\' => \'post\',
\'hierarchical\' => false,
\'rewrite\' => array(\'slug\' => \'work\', \'with_front\' => false),
\'query_var\' => \'portfolio\',
\'supports\' => array(\'title\', \'thumbnail\'),
\'menu_position\' => 5
));
}
add_action( \'init\', \'create_pc_db_taxonomies\', 0 );
function create_pc_db_taxonomies() {
register_taxonomy(
\'portfolio_tag\',
\'portfolio\',
array(
\'hierarchical\' => true,
\'label\' => \'Portfolio Tags\',
\'rewrite\' => array(\'slug\' => \'\', \'with_front\' => false)
)
);
}
我已经在我的主页上创建了一个自定义循环,并成功地显示了这种类型的帖子,这表明它们可以工作,但是当查看分类法存档时,我只得到一条消息,没有找到帖子。。。它正在寻找正确的模板来使用,只是看不到附加到该分类法的帖子。下面是分类法的代码。php
<?php if (have_posts()) : ?>
<ul id="gallery" class="portfolio-list clearfix">
<?php while (have_posts()) : the_post(); ?>
<li>
<?php if ( has_post_thumbnail() ) { ?>
<a class="fancybox" title="<?php the_title(); ?>" rel="bookmark" href="<?php
$attachments = get_children( array(\'post_parent\' => get_the_ID(), \'post_type\' => \'attachment\', \'post_mime_type\' =>\'image\') );
foreach ( $attachments as $attachment_id => $attachment ) {
echo wp_get_attachment_url( $attachment_id, \'medium\' );
} ?>">
<?php the_post_thumbnail(); ?>
</a>
<?php } else { ?>
<a class="fancybox" title="<?php the_title(); ?>" rel="bookmark" href="http://dummyimage.com/640x480/333/fff&text=x">
<img src="http://dummyimage.com/300x300/333/fff&text=x" alt="<?php the_title(); ?>" />
</a>
<?php } ?>
</li>
<?php endwhile; ?>
</ul>
<?php else : ?>
<p><?php _e(\'Sorry, no posts matched your criteria.\'); ?></p>
<?php endif; ?>
Any ideas why this is not working? Thanks