我正在寻找建立2个自定义的职位类型-宣传和;经营
我想做的是在宣传页上显示自定义帖子类型中每个帖子的特色缩略图。然后,它们将使用自定义模板链接到每个帖子。
我想对管理科也这样做。我已经创建了帖子类型,但当我单击缩略图时,我会被带到一个不包含任何相关信息的页面。
我使用的儿童主题是二十一二。
有人能帮忙吗?
用于cpt注册的代码
add_action(\'init\', \'publicity_register\');
function publicity_register() {
$labels = array(
//the (probably plural) name for our new post type
\'name\' => _x(\'Publicity\', \'post type general name\'),
//how you’d refer to this in the singular (such as ‘Add new ****’)
\'singular_name\' => _x(\'Publicity\', \'post type singular name\'),
\'add_new\' => _x(\'Add New\', \'publicity\'),
\'add_new_item\' => __(\'Add New Publicity Artist\'),
\'edit_item\' => __(\'Edit Publicity Artist\'),
\'new_item\' => __(\'New Publicity Artist \'),
\'view_item\' => __(\'View Publicity Artist\'),
\'search_items\' => __(\'Search Publicity\'),
\'not_found\' => __(\'Nothing found\'),
\'not_found_in_trash\' => __(\'Nothing found in Trash\'),
\'parent_item_colon\' => \'\'
);
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'show_ui\' => true,
\'capability_type\' => \'post\',
\'hierarchical\' => false,
\'rewrite\' => true,
\'supports\' => array(\'title\', \'editor\', \'thumbnail\'),
\'has_archive\' => true,
);
register_post_type( \'publicity\' , $args );
}
循环使用的代码
$args = array( \'post_type\' => \'publicity\', \'posts_per_page\' => 20 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
echo \'<div class="col-md-3 portfolio-item">\';
echo \'<a href="\' . get_permalink() . \'" title="\' . get_the_title() . \'">\';
echo get_the_post_thumbnail() . \' </a>\';
echo \'<div class="artist-name"><a href="\' . get_permalink() . \'"\';
echo \' title="\' . get_the_title() . \'">\' . get_the_title() . \'</a></div>\';
echo \'</div>\';
endwhile;
?>