WordPress - 自定义帖子类型永久链接冲突

时间:2013-03-19 14:13:08

标签: wordpress

我使用自定义帖子类型和自定义分类法的WordPress。

问题

我尝试使用路径/nyheter/bolag/post/创建帖子,但会将其重定向到/bolag/post/。这是因为我有一个自定义帖子类型与slug bolag,WP可能会尝试纠正路径。

这是如何解决的?代码,插件?

代码放在functions.php

<?php
add_action( 'init', 'create_post_type' );
add_action( 'init', 'register_taxonomies' );

function create_post_type() {
$args_bolag = array(
    'labels' => array(
        'name' => 'Bolag',
        'singular_name' => 'Bolag'
    ),
    'public' => true,
    'has_archive' => true,
    'rewrite' => array('slug' => 'bolag'),
);

$args_nyheter = array(
    'labels' => array(
        'name' => 'Nyheter',
        'singular_name' => 'Nyheter'
    ),
    'public' => true,
    'has_archive' => true,
    'rewrite' => array('slug' => 'nyheter'),
);

register_post_type( 'bolag', $args_bolag );
register_post_type( 'nyheter', $args_nyheter );
}

function register_taxonomies()
{
$args_firma = array(
    'label' => __( 'Firma' ),
    'rewrite' => array( 'slug' => 'nyheter/bolag' ),
    'hierarchical' => true,
);
register_taxonomy( 'firma', 'nyheter', $args_firma );
}

0 个答案:

没有答案
相关问题