WordPress-具有自定义帖子类型的永久链接
问题描述:
我创建了一个自定义帖子类型,如下所示,
I have created a custom post type as seen below,
function transactions_register() {
$args = array(
'label' => __('Transactions'),
'singular_label' => __('Transaction'),
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => array("slug" => "transaction"),
'supports' => array('title', 'editor', 'thumbnail')
);
register_post_type( 'transaction' , $args );
}
我已将永久链接设置为这样的/%category/%postname
,但是当我导航至交易时,URL看起来像这样,
I have set my permalinks to be like this /%category/%postname
however when I navigate to a transaction, the URL looks like this,
但是,这将返回以下服务器错误
However this returns the following server error
找不到页面
The page cannot be found
如何做到这一点,以便我的自定义帖子类型可以与我的永久链接设置一起使用?
How can I make it so my custom post type will work with my permalink setting?
答
无论何时添加自定义帖子类型,都只需转到设置"->永久链接",然后单击保存",或者单击更新"即可.它具有魔力.
Whenever you add custom post type, just go to Settings -> Permalinks and click on "Save" or was it "Update". It does the magic.