WordPress-具有自定义帖子类型的永久链接 [英] Wordpress -- permalink with custom post types

查看:88
本文介绍了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,

http://www.domian.com/transaction/test

但是,这将返回以下服务器错误

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.

这篇关于WordPress-具有自定义帖子类型的永久链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆