我是一个新的学习者,正在努力建立一个wordpress theme
我需要你的帮助在主题建设,我的问题是,我创建了一个自定义的职位类型名称是events
还创建了single-events.php
我的主题内的模板,以便只能显示事件帖子,但当我单击其帖子的永久链接时,它不会重定向到single-events.php
, 它重定向到索引页,请任何人给我一个例子解决。
/自定义邮政编码为/
add_action (\'init\', \'register_events_posttype\');
function register_events_posttype(){
$labels = array();
$args = array(
\'label\' => \'events\',
\'labels\' => $labels,
\'publicly_queryable\' => true,
\'rewrite\' => array(\'slug\' => \'events\'),
\'show_in_menu\' => true,
\'show_ui\' => true,
\'show_in_nav_menus\' => true,
\'show_in_rest\' => true,
\'menu_position\' => 2,
\'capability_type\'=>\'post\',
\'public\' => true,
\'has_archive\' => true,
\'menu_icon\' => \'dashicons-calendar-alt\',
\'supports\' => array(\'title\',\'editor\',\'thumbnail\', \'excerpt\',\'custom-fields\',\'thumbnail\', \'archives\',),
\'taxonomies\' => array(\'category\', \'post_tag\'),
\'rewrite\' => array(\'slug\' => \'events\',\'with_front\' => false)
);
register_post_type(\'events\', $args);
}
/和
single-events.php
代码为/
<?php
get_header();
?>
events post
<?php echo get_the_title();?>
<?php
get_footer();
?>
你能解决它吗?