最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

permalinks - How can I rewrite the URL of my custom taxonomy to include the year?

programmeradmin1浏览0评论

I've created a custom taxonomy that allows my school's newspaper to organize stories into special issues. However, some of the special issues we publish are the same every year. For example, our Black History Month special issue is published every February. Because the issues have the same name, they will have the same slug, and it will look like this:

What I have now:



I would like to rewrite the URL to include the year that the taxonomy was created. It seems like the date isn't stored by WordPress, so I was going to include it in an ACF custom field (I'm using the year elsewhere):

What I want:



This looks a lot like how hierarchical taxonomy URLs look, however the special-issue taxonomy is not:

register_taxonomy('special-issue', ['post'], [
    'labels' => [
        'name' => 'Special Issues',
        'singular_name' => 'Special Issue',
        'add_new_item' => 'Add New Issue',
        'not_found' => 'No special issues found.',
        'search_items' => 'Search',
        'view_item' => 'View Special Issue'
    ],
    'hierarchical' => false,
    'show_ui' => true,
    'show_admin_column' => false,
    'query_var' => true,
    'rewrite' => ['slug' => 'special'],
]);

Is this feasible, or should I just put the year in the slug?

What I might have to settle for:



发布评论

评论列表(0)

  1. 暂无评论