带有自定义帖子的WordPress中的一致URL

时间:2016-05-09 23:31:18

标签: php wordpress

我的自定义帖子的网址一致性问题。 我有一个页面显示给定类别中的所有帖子:

http://thedomain.com.au/tour_category/gbr/

当我点击该类别中的帖子时,我会收到以下网址:

http://thedomain.com.au/tours/reefsleep-under-the-stars/

我希望帖子的网址为:

http://thedomain.com.au/tour_category/gbr/reefsleep-under-the-stars/

我不知道如何实现这一目标。如果有帮助,我在functions.php中有以下代码:

// Our custom post type function
    function create_posttype() {

    register_post_type( 'tours',
    // CPT Options
        array(
            'labels' => array(
                'name' => __( 'Tours' ),
                'singular_name' => __( 'Tour' )
            ),
            'public' => true,
            'has_archive' => true,
            'rewrite' => array('slug' => 'tours'),
            'hierarchical' => true 
        )
    );
}
// Hooking up our function to theme setup
add_action( 'init', 'create_posttype' );
function my_taxonomies_tours() {
      $labels = array(
        'name'              => _x( 'Tour Categories', 'taxonomy general name' ),
        'singular_name'     => _x( 'Tour Category', 'taxonomy singular name' ),
        'search_items'      => __( 'Search Tour Categories' ),
        'all_items'         => __( 'All Tour Categories' ),
        'parent_item'       => __( 'Parent Tour Category' ),
        'parent_item_colon' => __( 'Parent Tour Category:' ),
        'edit_item'         => __( 'Edit Tour Category' ), 
        'update_item'       => __( 'Update Tour Category' ),
        'add_new_item'      => __( 'Add New Tour Category' ),
        'new_item_name'     => __( 'New Tour Category' ),
        'menu_name'         => __( 'Tour Categories' ),
      );
      $args = array(
        'labels' => $labels,
        'hierarchical' => true,
      );
      register_taxonomy( 'tour_category', 'tours', $args );
    }

    add_action( 'init', 'my_taxonomies_tours', 0 );

1 个答案:

答案 0 :(得分:1)

似乎您想要更改代码的这一部分

'rewrite' => array('slug' => 'tours'),

'rewrite' => array('slug' => 'tour_category/gbr'),

slug是域

之后的url的初始部分