修改默认类别(分类法)的重写slug,wordpress

时间:2016-12-03 05:49:31

标签: php wordpress

我想更改默认注册分类法,WordPress。

wordpress / wp-admin / edit-tags.php?taxonomy = category =它列出了帖子的类别..我想改变这些分类法的重写段,就像我们通常使用自定义分类法一样......

例如,请参阅下面的自定义分类法代码,

            add_rewrite_tag('%city_name%', '([^&/]+)');

            $rewrite_params = array(
                'slug' => 'm/%city_name%/jobs/categories',
                'with_front' => false
            );

            $labels = array(
                'name'              => __( 'Job Categories' ),
                'singular_name'     => __( 'Job Category' ),
                'search_items'      => __( 'Search Job Categories' ),
                'all_items'         => __( 'All Job Categories' ),
                'parent_item'       => __( 'Parent Job Category' ),
                'parent_item_colon' => __( 'Parent Job Category:' ),
                'edit_item'         => __( 'Edit Job Category' ), 
                'update_item'       => __( 'Update Job Category' ),
                'add_new_item'      => __( 'Add New Job Category' ),
                'new_item_name'     => __( 'New Job Category' ),
                'menu_name'         => __( 'Job Categories' ),
            );

            $capabilities = array(
                'manage_terms'      => 'manage_job_category',
                'edit_terms'        => 'edit_job_category',
                'delete_terms'      => 'delete_job_category',
                'assign_terms'      => 'assign_job_category'            
            );

            $args = array(
                'labels'            => $labels,
                'public'            => true,
                'hierarchical'      => true,
                'show_ui'           => true,
                'show_in_nav_menus' => true,
                'query_var'         => true,
                'rewrite'           => $rewrite_params,
                'capabilities'      => $capabilities,                       
            );

            register_taxonomy( 'job_category', 'jobs', $args );

在这里你可以看到我使用%city_name%和slug,所以我可以在城市里找到工作..我需要用默认帖子做同样的事情..所以我可以根据这个slug过滤城市内的帖子...

类似

           add_rewrite_tag('%city_name%', '([^&/]+)');

                $rewrite_params = array(
                    'slug' => '%city_name%/category',
                    'with_front' => false
                );
谁能帮助我?

0 个答案:

没有答案