Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Custom Taxonomy in the Word press

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 272
    Comment on it

    We can add taxonomy to our custom post type.

    Adding taxonomy means adding new category option in our custom post type.

    We use taxonomy to basically categorize the data.

    We create the groups of the similar type.

    To add custom taxonomy we use this function in our4 function.php

    function people_init() {
        // create a new taxonomy
        register_taxonomy(
            'people',
            'post',
            array(
                'label' => _( 'People' ),
                'rewrite' => array( 'slug' => 'person' ),
                'capabilities' => array(
                    'assign_terms' => 'edit_guides',
                    'edit_terms' => 'publish_guides'
                )
            )
        );
    }
    add_action( 'init', 'people_init' );
    

    the "people" taxonomy is defined. It's defined to work for posts, and a rewrite slug is defined to make the url into '/person/' instead of '/people/'. The capabilities line is optional. Without it, WordPress will default capabilities to the same users as posts. As shown above, this will allow any user with the custom "edit_guides" capability to assign the taxonomy to a post and any user with the custom "publish_guides" capability to create new taxonomy items.

    We can term.

    We can manage term.

    We can edit term.

    We can delete term.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: