Wordpress — permalink with custom post types

空扰寡人 提交于 2019-12-08 03:16:50

问题


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 );

}

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?


回答1:


Whenever you add custom post type, just go to Settings -> Permalinks and click on "Save" or was it "Update". It does the magic.




回答2:


Every time you create custom post type or custom taxonomy you have to goto Settings -> Permalinks and hit save. its wordpress known bug.



来源:https://stackoverflow.com/questions/5486560/wordpress-permalink-with-custom-post-types

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!