Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




create_initial_taxonomies [ WordPress Function ]

create_initial_taxonomies ( No parameters )
Defined at:



Creates the initial taxonomies.

This function fires twice: in wp-settings.php before plugins are loaded (for backwards compatibility reasons), and again on the 'init' action. We must avoid registering rewrite rules before the 'init' action.

Source


<?php
function create_initial_taxonomies() {
    global 
$wp_rewrite;

    if ( ! 
did_action'init' ) ) {
        
$rewrite = array( 'category' => false'post_tag' => false'post_format' => false );
    } else {
        
$post_format_base apply_filters'post_format_rewrite_base''type' );
        
$rewrite = array(
            
'category' => array(
                
'hierarchical' => true,
                
'slug' => get_option('category_base') ? get_option('category_base') : 'category',
                
'with_front' => ! get_option('category_base') || $wp_rewrite->using_index_permalinks(),
                
'ep_mask' => EP_CATEGORIES,
            ),
            
'post_tag' => array(
                
'slug' => get_option('tag_base') ? get_option('tag_base') : 'tag',
                
'with_front' => ! get_option('tag_base') || $wp_rewrite->using_index_permalinks(),
                
'ep_mask' => EP_TAGS,
            ),
            
'post_format' => $post_format_base ? array( 'slug' => $post_format_base ) : false,
        );
    }

    
register_taxonomy'category''post', array(
        
'hierarchical' => true,
        
'query_var' => 'category_name',
        
'rewrite' => $rewrite['category'],
        
'public' => true,
        
'show_ui' => true,
        
'_builtin' => true,
    ) );

    
register_taxonomy'post_tag''post', array(
         
'hierarchical' => false,
        
'query_var' => 'tag',
        
'rewrite' => $rewrite['post_tag'],
        
'public' => true,
        
'show_ui' => true,
        
'_builtin' => true,
    ) );

    
register_taxonomy'nav_menu''nav_menu_item', array(
        
'public' => false,
        
'hierarchical' => false,
        
'labels' => array(
            
'name' => __'Navigation Menus' ),
            
'singular_name' => __'Navigation Menu' ),
        ),
        
'query_var' => false,
        
'rewrite' => false,
        
'show_ui' => false,
        
'_builtin' => true,
        
'show_in_nav_menus' => false,
    ) );

    
register_taxonomy'link_category''link', array(
        
'hierarchical' => false,
        
'labels' => array(
            
'name' => __'Link Categories' ),
            
'singular_name' => __'Link Category' ),
            
'search_items' => __'Search Link Categories' ),
            
'popular_items' => null,
            
'all_items' => __'All Link Categories' ),
            
'edit_item' => __'Edit Link Category' ),
            
'update_item' => __'Update Link Category' ),
            
'add_new_item' => __'Add New Link Category' ),
            
'new_item_name' => __'New Link Category Name' ),
            
'separate_items_with_commas' => null,
            
'add_or_remove_items' => null,
            
'choose_from_most_used' => null,
        ),
        
'query_var' => false,
        
'rewrite' => false,
        
'public' => false,
        
'show_ui' => false,
        
'_builtin' => true,
    ) );

    
register_taxonomy'post_format''post', array(
        
'public' => true,
        
'hierarchical' => false,
        
'labels' => array(
            
'name' => _x'Format''post format' ),
            
'singular_name' => _x'Format''post format' ),
        ),
        
'query_var' => true,
        
'rewrite' => $rewrite['post_format'],
        
'show_ui' => false,
        
'_builtin' => true,
        
'show_in_nav_menus' => current_theme_supports'post-formats' ),
    ) );
}
?>

Examples [ wp-snippets.com ]

Top Google zoekresultaten

Meer ...

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics