Title: Add support to custom post type
Last modified: August 22, 2016

---

# Add support to custom post type

 *  Resolved Anonymous User 13362967
 * (@anonymized-13362967)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/add-support-to-custom-post-type/)
 * How to add support for custom post type?
 * [http://codex.wordpress.org/Function_Reference/register_post_type](http://codex.wordpress.org/Function_Reference/register_post_type)
 * [https://wordpress.org/plugins/user-specific-content/](https://wordpress.org/plugins/user-specific-content/)

Viewing 14 replies - 1 through 14 (of 14 total)

 *  Plugin Author [Bainternet](https://wordpress.org/support/users/bainternet/)
 * (@bainternet)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/add-support-to-custom-post-type/#post-5338437)
 *     ```
       //using a filter hook
       add_filter('USC_allowed_post_types','usc_filter_post_types');
       function usc_filter_post_types($types){
       	//add a custom post type
       	$types[] = 'MY_CUSTOM_POST_TYPE_NAME';
       	//remove a post type
       	if(($key = array_search('post', $types)) !== false) {
           	unset($types[$key]);
       	}
       }
   
       //or using action hook
       add_action('USC_add_meta_box','usc_add_metabox_to_ctp');
       function usc_add_metabox_to_ctp($obj){
       	add_meta_box(
       		'User_specific_content',
       		__( 'User specific content box'),
       		array($obj,'User_specific_content_box_inner'),
       		'MY_CUSTOM_POST_TYPE_NAME'
       	);
       }
       ```
   
 *  Thread Starter Anonymous User 13362967
 * (@anonymized-13362967)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/add-support-to-custom-post-type/#post-5338439)
 * Thanks 🙂
 *  [Kahil](https://wordpress.org/support/users/kahil/)
 * (@kahil)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/add-support-to-custom-post-type/#post-5338566)
 * This doesn’t work for custom post types. I just tried it for WooCommerce products.
   The field array shows up on the edit screen for products…but they are still visible
   to everyone. The listings in the store and the dedicated page for the product.
 * Thoughts?
 *  [oshi](https://wordpress.org/support/users/thugzanime/)
 * (@thugzanime)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/add-support-to-custom-post-type/#post-5338594)
 * I been looking for this all day. cant wait to try this out and see the results.
   Thanks Bainternet
 *  [oshi](https://wordpress.org/support/users/thugzanime/)
 * (@thugzanime)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/add-support-to-custom-post-type/#post-5338595)
 * Sadly just test it the code and no luck, I have a custom post type, and the user
   specific content option dasn’t display.
 * has anyone solve this?
 *  Thread Starter Anonymous User 13362967
 * (@anonymized-13362967)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/add-support-to-custom-post-type/#post-5338596)
 * It works for me
 *  [oshi](https://wordpress.org/support/users/thugzanime/)
 * (@thugzanime)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/add-support-to-custom-post-type/#post-5338597)
 * Hey @iowjfowei can you please tell me where i may went wrong here.
 * I understand I supposes to change the MY_CUSTOM_POST_TYPE_NAME
    to my custom 
   post type slug name right..?
 * example see the code below am using provided from [@bainternet](https://wordpress.org/support/users/bainternet/)
 *     ```
       //using a filter hook
       add_filter('USC_allowed_post_types','usc_filter_post_types');
       function usc_filter_post_types($types){
       	//add a custom post type
       	$types[] = 'portfolio';
       	//remove a post type
       	if(($key = array_search('post', $types)) !== false) {
           	unset($types[$key]);
       	}
       }
   
       //or using action hook
       add_action('USC_add_meta_box','usc_add_metabox_to_ctp');
       function usc_add_metabox_to_ctp($obj){
       	add_meta_box(
       		'User_specific_content',
       		__( 'User specific content box'),
       		array($obj,'User_specific_content_box_inner'),
       		'portfolio'
       	);
       }
       ```
   
 *  Thread Starter Anonymous User 13362967
 * (@anonymized-13362967)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/add-support-to-custom-post-type/#post-5338598)
 * You use both codes? Use a filter hook or action hook, not both (I use second 
   one) 😉
 *  [oshi](https://wordpress.org/support/users/thugzanime/)
 * (@thugzanime)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/add-support-to-custom-post-type/#post-5338599)
 * Hi @iowjfowei Thanks for getting back at me and no i tried the first code not
   a luck then i tried the second one still not a luck.
 * All I want is to display the User Specific Content option on the custom post 
   so i can apply that post for a specific user.
 *  [lmolina](https://wordpress.org/support/users/lmolina/)
 * (@lmolina)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/add-support-to-custom-post-type/#post-5338610)
 * Thanks. Work for me.
 *  [Jerrad](https://wordpress.org/support/users/jjgleim/)
 * (@jjgleim)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/add-support-to-custom-post-type/#post-5338618)
 * Thanks for the code – I was able to get the action hook to work.
 * How would you add it to multiple post types?
 * Thanks!
 * Jerrad
 *  [X-Raym](https://wordpress.org/support/users/x-raym/)
 * (@x-raym)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/add-support-to-custom-post-type/#post-5338641)
 * I confirm the action hook works.
 * Thank you so much!!
 *  [Mike-Ism](https://wordpress.org/support/users/mike-ism/)
 * (@mike-ism)
 * [11 years ago](https://wordpress.org/support/topic/add-support-to-custom-post-type/#post-5338642)
 * Hi, I got this working, but could you please help me figure out how to use it
   on multiple custom post types? would it be like this:
 *     ```
       add_action('USC_add_meta_box','usc_add_metabox_to_ctp');
       function usc_add_metabox_to_ctp($obj){
       	add_meta_box(
       		'User_specific_content',
       		__( 'User specific content box'),
       		array($obj,'User_specific_content_box_inner'),
       		'portfolio' , 'movies' , 'reviews'
       	);
       }
       ```
   
 *  [Mike-Ism](https://wordpress.org/support/users/mike-ism/)
 * (@mike-ism)
 * [11 years ago](https://wordpress.org/support/topic/add-support-to-custom-post-type/#post-5338643)
 * Solved the issue with the help of a different community:
 *     ```
       add_action('USC_add_meta_box','usc_add_metabox_to_ctp');
   
       function usc_add_metabox_to_ctp($obj){
   
           $post_types = array(
               'portfolio',
               'my_other_post_type',
               'page',
               'post' // etc
           ); 
   
           foreach ( $post_types as $post_type ) {
               add_meta_box(
                   'User_specific_content',
                   __( 'User specific content box'),
                   array($obj,'User_specific_content_box_inner'),
                   $post_type
               );
           }
       }
       ```
   

Viewing 14 replies - 1 through 14 (of 14 total)

The topic ‘Add support to custom post type’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/user-specific-content_ffffff.svg)
 * [User Specific Content](https://wordpress.org/plugins/user-specific-content/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/user-specific-content/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/user-specific-content/)
 * [Active Topics](https://wordpress.org/support/plugin/user-specific-content/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/user-specific-content/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/user-specific-content/reviews/)

## Tags

 * [custom post type](https://wordpress.org/support/topic-tag/custom-post-type/)

 * 14 replies
 * 8 participants
 * Last reply from: [Mike-Ism](https://wordpress.org/support/users/mike-ism/)
 * Last activity: [11 years ago](https://wordpress.org/support/topic/add-support-to-custom-post-type/#post-5338643)
 * Status: resolved