Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 常规帖子和自定义帖子类型permalink wordpress_Php_Wordpress_Post_Types_Permalinks - Fatal编程技术网

Php 常规帖子和自定义帖子类型permalink wordpress

Php 常规帖子和自定义帖子类型permalink wordpress,php,wordpress,post,types,permalinks,Php,Wordpress,Post,Types,Permalinks,大家好,我用xampp在本地开发wordpress主题,我将永久链接更改为/%category%/%postname%/并且一切正常,但是在我创建自定义帖子类型后,永久链接我的常规帖子链接给我错误404页面和我的自定义帖子类型链接正常工作,当我取消激活自定义帖子类型我的常规帖子链接时再次正常工作,2天搜索,但没有果断措施 这是我的自定义邮件类型代码 您是否已转到管理员中的永久链接设置并点击保存?这通常可以解决问题。你可以试试这个插件 <?php function name_

大家好,我用xampp在本地开发wordpress主题,我将永久链接更改为/%category%/%postname%/并且一切正常,但是在我创建自定义帖子类型后,永久链接我的常规帖子链接给我错误404页面和我的自定义帖子类型链接正常工作,当我取消激活自定义帖子类型我的常规帖子链接时再次正常工作,2天搜索,但没有果断措施

这是我的自定义邮件类型代码


您是否已转到管理员中的永久链接设置并点击保存?这通常可以解决问题。你可以试试这个插件
  <?php 

    function name_post(){
        register_post_type('name',
            array(
                'labels' => array(
                    'name' =>  'Names', 'wp_hours',
                    'singular_name' => 'Name', 'wp_hours',
                    'all_items' => 'All Names', 'wp_hours',
                    'add_new' => 'Add New', 'wp_hours',
                    'add_new_item' => 'Add New Name', 'wp_hours',
                    'edit' => 'Edit', 'wp_hours',
                    'edit_item' => 'Edit Name', 'wp_hours',
                    'new_item' => 'New Name', 'wp_hours',
                    'view_item' => 'View Names', 'wp_hours',
                    'search_items' => 'Search Names', 'wp_hours',
                    'not_found' => 'Nothing found in Database', 'wp_hours',
                    'not_found_in_trash' => 'Nothing found in Trash', 'wp_hours',
                    'parent_item_colon' => ''
                ),
                'public' => true,
                'has_archive' => 'name',
                'public_queryable' => true,
                'show_ui' => true,
                'show_in_menu' => true,
                'capaility' => 'post',
                'menu_position' => 5,
                'rewrite' => array('slug' => 'name'),
                'menu_icon' => 'dashicons-groups',
                'supports' => array('title', 'editor', 'thumbnail', 'excerpt', 'custom-fields'),
                'taxonomies' => array('category', 'post_tag')
            ));
    }

    add_action('init','name_post');

    function names_taxonomies(){
        register_taxonomy(
            'Country',
            'name',
            array(
                'label' => __('Conutry'),
                'rewrite' => array('slug' => 'country'),
                'hierarchical' => ture,
            )
        );

        register_taxonomy(
            'Age',
            'name',
            array(
                'label' => __('Age'),
                'rewrite' => array('slug' => 'age'),
                'hierarchical' => false,
            )
        );
    }

    add_action('init', 'names_taxonomies');

    function my_rewrite_flush() {
        my_custom_posttypes();
        flush_rewrite_rules();
    }
    register_activation_hook( __FILE__, 'my_rewrite_flush' );   

 ?>