我有一个自定义的帖子类型,叫做support 我还有两个角色:manager 和employee.
现在,我想根据角色显示帖子详细信息。请帮帮我。
自定义邮政编码
// supports
add_action( \'init\', \'register_cpt_support\' );
function register_cpt_support() {
$labels = array(
\'name\' => __( \'support\', \'support\' ),
\'singular_name\' => __( \'support\', \'support\' ),
\'add_new\' => __( \'Add New\', \'support\' ),
\'add_new_item\' => __( \'Add New support\', \'support\' ),
\'edit_item\' => __( \'Edit support\', \'support\' ),
\'new_item\' => __( \'New support\', \'support\' ),
\'view_item\' => __( \'View support\', \'support\' ),
\'search_items\' => __( \'Search support\', \'support\' ),
\'not_found\' => __( \'No support found\', \'support\' ),
\'not_found_in_trash\' => __( \'No support found in Trash\', \'support\' ),
\'parent_item_colon\' => __( \'Parent support:\', \'support\' ),
\'menu_name\' => __( \'support\', \'support\' ),
);
$args = array(
\'labels\' => $labels,
\'hierarchical\' => false,
\'supports\' => array( \'title\',\'editor\', \'excerpt\', \'author\', \'thumbnail\', \'trackbacks\', \'custom-fields\', \'comments\', \'revisions\', \'page-attributes\' ),
\'taxonomies\' => array( \'category\', \'post_tag\', \'page-category\' ),
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'show_in_nav_menus\' => true,
\'menu_icon\' => \'dashicons-businessman\',
\'show_in_nav_menus\' => true,
\'publicly_queryable\' => true,
\'exclude_from_search\' => true,
\'has_archive\' => true,
\'query_var\' => true,
\'can_export\' => true,
\'rewrite\' => true,
// \'show_in_rest\' => true,
\'capability_type\' => \'post\'
);
register_post_type( \'support\', $args );
}
前端代码
<div class="work">
<div class="work-wrap">
<h2>FAQ Articles…</h2>
<ul class="clearfix item-list">
<?php query_posts(\'category_name=home&post_type=support&posts_per_page=-1&order=ASC\'); while (have_posts()) : the_post();
$image_id = get_post_thumbnail_id();
$image_url = wp_get_attachment_image_src($image_id,\'\', true);
?>
<a href="<?php the_permalink(); ?>"><li class="work-box">
<img src="<?php echo $image_url[0]; ?>" alt="y1" style="max-width:100%;" />
<h3><?php the_title(); ?></h3>
</li></a>
<?php endwhile; ?>
</ul>
<a href="#" class="btn more-trigger">View more articles...</a>
</div>
</div>