我正在尝试创建自定义帖子(&A);使用以下代码张贴标签
function cptportfolioPost_init() {
register_post_type( \'portfolio\',
array(
\'labels\' => array(
\'name\' => __( \'Portfolio\' ),
\'singular_name\' => __( \'Portfolio\' )
),
\'public\' => true,
\'has_archive\' => true,
\'menu_icon\' => \'dashicons-calendar-alt\',
\'taxonomies\' => array(\'post_tag\'),
\'supports\' => array(
\'title\',
\'editor\',
\'excerpt\',
\'revisions\',
\'thumbnail\',
\'author\',
\'page-attributes\',
)
)
);
}
add_action( \'init\', \'cptportfolioPost_init\' );
使用此代码在帖子页面上获取标签
<?php $tags = get_tags();
$html = \'<div class="post-tags-wrap">\';
foreach ( $tags as $tag ) {
$tag_link = get_tag_link( $tag->term_id );
$html .= "<a href=\'{$tag_link}\' title=\'{$tag->name} Tag\' class=\'{$tag->slug}\'>";
$html .= "{$tag->name}</a>";
}
$html .= \'</div>\';
echo $html;?>
在dashboard中,我的自定义帖子有一个标签选项,在前台的帖子页面上也显示选定的标签,但当我单击标签链接时,标签页面不显示与该标签相关的自定义帖子,只显示与该标签相关的WordPress默认帖子,因此如何在标签页面上获取我的自定义帖子