2016-07-12 5 views
0

На моем веб-сайте есть пользовательский тип сообщения: продукты и привязаны к пользовательской таксономии: категории.Смена пули для пользовательского типа сообщения привела к 404 для одного типа сообщений и страниц

В настоящее время мои URL-адрес для конкретного продукта, как это:

example.com/product/laptop/acer/acerproductname 

Как я хотел, чтобы удалить пробку и URL, должен выглядеть следующим образом

example.com/laptop/acer/acerproductname 

так, чтобы удалить это, я изменил слизняк при регистрации настраиваемого типа сообщений.

из

$slug = product."/%product_category%/%product_brand%"; 

в

$slug = "/%product_category%/%product_brand%"; 

Теперь функция пост регистра выглядеть следующим образом

public function aw_register_post_type(){   
 
     // Labels 
 
\t $labels = array(
 
\t \t 'name' => __('Products','framework'), 
 
\t \t 'singular_name' => __('Product','framework'), 
 
\t \t 'add_new' => __('Add new','framework'), 
 
\t \t 'add_new_item' => __('Add new product','framework'), 
 
\t \t 'edit_item' => __('Edit','framework'), 
 
\t \t 'new_item' => __('New product','framework'), 
 
\t \t 'view_item' => __('View product','framework'), 
 
\t \t 'search_items' => __('Search product','framework'), 
 
\t \t 'not_found' => __('No product found','framework'), 
 
\t \t 'not_found_in_trash' => __('No product found in trash','framework'), 
 
\t \t 'parent_item_colon' => '', 
 
\t \t 'menu_name' => __('Products','framework') 
 
\t); 
 
\t 
 
\t $short_url = (get_option('tz_products_short_url') != '') ? get_option('tz_products_short_url') : 0; 
 
\t $slug_first_part = ((get_option('tz_custom_products_slug') != '') ? get_option('tz_custom_products_slug') : 'product'); 
 
\t if($short_url == 1) { 
 
\t \t $slug = $slug_first_part; 
 
\t \t 
 
\t } else { 
 
\t \t $slug = "/%product_category%/%product_brand%"; 
 

 
\t } 
 
\t $rewrite = array( 
 
    \t  \t 'slug'   => $slug, 
 
\t \t //'with_front' => false 
 
); 
 
\t 
 
\t // Arguments 
 
\t $args = array(
 
\t \t 'labels' => $labels, 
 
\t \t 'public' => true, 
 
\t \t 'publicly_queryable' => true, 
 
\t \t 'show_ui' => true, 
 
\t \t 'show_in_menu' => true, 
 
\t \t 'query_var' => true, 
 
\t \t 'menu_icon' => get_stylesheet_directory_uri().'/img/admin/admin-products.png', 
 
\t \t 'rewrite' => true, 
 
\t \t 'capability_type' => 'post', 
 
\t \t //'rewrite' => array("slug" => $slug), // Permalinks format 
 
\t \t 'rewrite' => $rewrite, 
 
\t \t 'has_archive' => true, 
 
\t \t 'hierarchical' => false, 
 
\t \t 'menu_position' => null, 
 
\t \t 'taxonomies' => array('post_tag'), 
 
\t \t 'supports' => array('title','editor','author','thumbnail','excerpt', 'comments', 'tags') 
 
\t);

Теперь URL-адреса для пользовательского почтового типа именно то, что я хотел, чтобы это

example.com/laptop/acer/acerproductname 

Главная проблема

После изменения тихоход мои блоги и другие страницы теперь показывая сообщение об ошибке 404. Какова может быть возможная причина и каково возможное решение этого.

+0

Это работает, если вы раскомментируете 'with_front' => false? Вы делаете flush_rewrite_rules() после изменений? –

+0

Разоблачение не имеет значения. Нет, я не. –

+0

Покраснел он все еще без разницы –

ответ

0

Попробуйте добавить это в ваш functions.php

flush_rewrite_rules(); 

закоментируйте, как только вы обновляли страницу.

+0

уже пробовал. Не использовать. как обсуждалось с некоторыми другими разработчиками. Он сказал, что нужно добавить еще одну строку правил перезаписи в functions.php –

 Смежные вопросы

  • Нет связанных вопросов^_^