Anladığım kadarıyla bir
Custom Post Type ekledin ve bu özel yazı biçiminde
"kategori" etiketlerini kaldırmak istiyorsun. Bu çok basit.
add_action( 'init', 'create_posttype' );
function create_posttype() {
register_post_type( 'haber',
array(
'labels' => array(
'name' => 'Blog Yazıları',
'singular_name' => 'Blog',
'add_new' => 'Yeni Blog Yazısı Ekle',
'add_new_item' => 'Yeni Blog Yazısı Ekle',
'edit' => 'Yazıyı Düzenle',
'edit_item' => 'Yazıyı Düzenle',
'new_item' => 'Yeni Blog Yazısı Ekle',
'view' => 'Yazıyı Görüntüle',
'view_item' => 'Yazıyı Görüntüle',
'search_items' => 'Blog Yazılarında Ara',
'not_found' => 'Yazı Bulunamadı',
'not_found_in_trash' =>
'Yazı Bulunamadı',
'parent' => 'Tüm Blog Yazıları'
),
'show_ui' => true,
'capability_type' => 'post',
'supports' =>
array( 'title', 'editor', 'comments',
'thumbnail', 'post-formats', 'author', 'excerpt', 'trackbacks', 'custom-fields', 'revisions', 'page-attributes', 'post-formats' ),
'query_var' => true,
'menu_icon' =>'dashicons-location-alt',
'rewrite' => true,
'public' => true,
'menu_position' => 5,
'taxonomies' => array('post_tag','category'),
'hierarchical' => true,
'has_archive' => true,
'can_export' => true,
)
);Bu kod normal özel yazı biçimi ekliyor. Fakat sen bu yazı biçiminin "kategori" desteğini kaldırmak istiyorsan 'taxonomies' kısmını değiştirmen gerekir.
'taxonomies' => array('post_tag','category'),
burada category kısmını kaldırırsan o özel alanda kategoriler desteklenmez
'taxonomies' => array('post_tag'),İllaki kategori desteklesin ama URL'de kategori yazısı olmasın diyorsan:
function fix_slash( $string, $type ) { global $wp_rewrite; if ( $wp_rewrite->use_trailing_slashes == false ) { if ( $type != 'single' && $type != 'category' ) return trailingslashit( $string ); if ( $type == 'single' && ( strpos( $string, '.html/' ) !== false ) ) return trailingslashit( $string ); if ( $type == 'category' && ( strpos( $string, 'category' ) !== false ) ) { $aa_g = str_replace( "/category/", "/", $string ); return trailingslashit( $aa_g ); } if ( $type == 'category' ) return trailingslashit( $string ); } return $string; } add_filter( 'user_trailingslashit', 'fix_slash', 55, 2 );bunu functions.php dosyane ekle.
Bu da benden sana hediye olsun. CPT eklediğin dosyanın en altına ekle. Arama sonuçlarındaki sorunların düzelir:
function add_custom_types_to_tax( $query ) {
if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
// Get all your post types
$post_types = get_post_types();
$query->set( 'post_type', $post_types );
return $query;
}
}
add_filter( 'pre_get_posts', 'add_custom_types_to_tax' );