显示自定义分类,就像 Wordpress 如何分类

问题描述

需要帮助。

我需要为我创建的每个自定义分类法创建一个存档,但我不知道哪里出错了。

自定义帖子类型是:- single-spotlight.PHP

  1. 我在我的functions.PHP 中创建了自定义帖子类型,它们都可以正常工作,并且在它们各自的slug 之后显示良好。 例如。 https://sitename.co.uk/spotlight/post-title/

  2. 然后,我为此帖子类型创建了自定义分类法并对变量进行了分类周四、周五、周六和周日。 然后对于每个单独的帖子,勾选帖子应该出现的日期。

使用:- archive-spotlight.PHP

  1. 存档按照预期按照 slug 路径在每个帖子中很好地循环。 https://sitename.co.uk/spotlight/

  2. 但是,我也想要为每个分类日的存档,并且希望有一个;- taxonomy.PHP (我认为 ??) 模板与 category.PHP 在普通 wordpress 帖子循环、生态系统中的作用完全相同。

要在以下位置找到循环档案:- 弹道。 https://sitename.co.uk/spotlight/friday 要么 https://sitename.co.uk/friday

但是,这些天我无法链接到存档,并且尝试创建多个直接模板来这样做(如下所列)以将帖子通过但没有成功。

archive-spotlight-friday.PHP
taxonomy.PHP
taxonomy-friday.PHP

欢迎提供一些建议,代码如下。 提前致谢。

// Spotlight Post
function custom_spotlight_post_type()
{  
$labels = array(
'name' => 'Spotlight','singular_name' => 'Spotlight','add_new' => 'Add A Spotlight','all_items' => 'All Spotlights','add_new_item' => 'New Spotlight','edit_item' => 'Edit Spotlight','new_item' => 'New Spotlight','view_items' => 'View The Spotlights','search_items' => 'Search Spotlight','not_found' => 'No Spotlights Found','not_found_in_trash' => 'No Spotlights Found In Trash','parent_item_colon' => '','menu_name' => 'Spotlight'
);
$args = array(
'labels' => $labels,'public' => true,'has_archive' => true,'publicly_queryable' => true,'show_ui' => true,'query_var' => true,'rewrite' => true,'show_in_menu' => true,'capability_type' => 'post','hierarchical' => false,'supports' => array(
'title','custom-fields','post-formats','revisions'
),//'taxonomies' => array('category'),'exclude_from_search' => false,'menu_icon' => 'dashicons-tag'
);
register_post_type('spotlight',$args);
}
add_action('init','custom_spotlight_post_type');

// Spotlight Taxonomy
function custom_spotlight_taxonomy()
{
$labels = array(
'name' => 'Event Days','singular_name' => 'Event Day','search_items' => 'Search Event Days','all_items' => 'All Event Days','edit_item' => 'Edit Event Days','update_item' => 'Update Event Days','add_new_item' => 'Add A New Event Day','new_item_name' => 'New Event Day','menu_name' => 'Event Days'
);
$args = array(
'hierarchical' => true,'labels' => $labels,'show_admin_column' => true,'rewrite' => array(
'slug' => 'spotlight'
)  
);
register_taxonomy('spotlight',array('spotlight'),'custom_spotlight_taxonomy');

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)