Leave a suggestion

If this tutorial is not what you were looking for, you still have any questions, suggestions or concerns - feel free to let us know. Please help us to serve you better!

Your Name

Your Email

Your Message (required)

captcha

WordPress. How to enable and output post tags for custom post types

This tutorial is going to show you how to add support for custom post type and output post tags to your WordPress template.

For instance, your template comes with  custom posts called “Services” (or “Clients”, “Our team”, “Slides” depending on your template) and you want to add tags to it. To do this,

  1. Open the theme-init.php file located  in the \wp-content\themes\theme###\includes folder on your server to edit.
  2. Look for the part of code related to your custom post. E.g.
  3. /* Services */
    function my_post_type_services() {
    	register_post_type( 'services',
                    array(
    				'label' => __('Services'),
    				'public' => true,
    				'show_ui' => true,
    				'show_in_nav_menus' => false,
    				'menu_position' => 5,
    				'rewrite' => array(
    					'slug' => 'services-view',
    					'with_front' => FALSE,
    				),
    				'supports' => array(
    						'title',
    						'thumbnail',
    						'editor')
    					)
    				);
    }
    
    Where you  need to change this part 
    
    	'supports' => array(
    						'title',
    						'thumbnail',
    						'editor')
    					)
    				);
    }
    

    To

    'supports' => array(
    						'title',
    						'thumbnail',
    						'editor'
            ),
            'taxonomies' => array('category', 'post_tag') // this is IMPORTANT
        ));
    

    The whole part will look like this

    /* Services */
    function my_post_type_services() {
    	register_post_type( 'services',
                    array(
    				'label' => __('Services'),
    				'public' => true,
    				'show_ui' => true,
    				'show_in_nav_menus' => false,
    				'menu_position' => 5,
    				'rewrite' => array(
    					'slug' => 'services-view',
    					'with_front' => FALSE,
    				),
    				'supports' => array(
    						'title',
    						'thumbnail',
    						'editor'
            ),
            'taxonomies' => array('category', 'post_tag') // this is IMPORTANT
        ));
    }
    
  4. Save the changes and update the file on your server with them.
  5. Now you can  log into your WordPress admin and open the custom posts menu. You will find new options there like “Tags” and “Categories” that previously were available in the Posts only.

Feel free to check the detailed video tutorial below:

WordPress. How to enable and output post tags for custom post types