Title: Custom Post Types and Plugins
Last modified: August 19, 2016

---

# Custom Post Types and Plugins

 *  Resolved [whipd09](https://wordpress.org/support/users/whipd09/)
 * (@whipd09)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/custom-post-types-and-plugins/)
 * Guys,
 * I can’t seem to find any discussion on this. (In regards to custom post types
   and WordPress 3)
 * If you have existing plugins (pre WP3 plugins) that operate within the _Add New
   Post_ screen (eg. a Related Posts box that let’s you choose related posts to 
   the new post you’re creating). Is there an easy way to make them work for _Custom
   Post Type_ situations as well? Or does it require the plugin author to make drastic
   changes to work with Custom Post Types in the WP3 era?

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

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/custom-post-types-and-plugins/#post-1549028)
 * > Or does it require the plugin author to make drastic changes to work with Custom
   > Post Types in the WP3 era?
 * Most likely. But you might want to provide a link to the related posts plugin
   you are talking about and I’ll tag this thread so the plugin author might see
   your request.
 *  Thread Starter [whipd09](https://wordpress.org/support/users/whipd09/)
 * (@whipd09)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/custom-post-types-and-plugins/#post-1549189)
 * Yeah, thanks It’s the Microkids Related Posts [http://www.microkid.net/wordpress/related-posts/](http://www.microkid.net/wordpress/related-posts/)
 *  [qw3rt7](https://wordpress.org/support/users/qw3rt7/)
 * (@qw3rt7)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/custom-post-types-and-plugins/#post-1549196)
 * Should not be difficult at all provided the plugin author hasn’t encrypted their
   code.
    Is explained well here: [http://wordpress.org/support/topic/396712?replies=6](http://wordpress.org/support/topic/396712?replies=6)
 *  Thread Starter [whipd09](https://wordpress.org/support/users/whipd09/)
 * (@whipd09)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/custom-post-types-and-plugins/#post-1549241)
 * Thanks qw3rt7! You’ve saved me a lot of time.
 *  [microkid](https://wordpress.org/support/users/microkid/)
 * (@microkid)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/custom-post-types-and-plugins/#post-1549246)
 * Hi whipd09,
 * I’m trying to find the time to do some updates on my plugin soon. Can you elaborate
   on what you would like to see in a new version regarding the new Custom Post 
   Types feature?
 * Thanks
 *  Thread Starter [whipd09](https://wordpress.org/support/users/whipd09/)
 * (@whipd09)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/custom-post-types-and-plugins/#post-1549247)
 * Thanks for the reply microkid.
 * The plugin is amazing in itself, so **basically I’d just like to be able to use
   it with custom post types**. If you saw me in that other thread I managed to ‘
   hack’ it to _appear_ in a custom post type but it still searches for regular 
   posts instead of the new post types.
 * So it would be great if:
    1. If I had a Custom Post Type of ‘**Portfolio**‘. 
   When I create a new portfolio post, I can choose a couple of related portfolio
   posts to accompany it. The ability to have the plugin ignore regular posts would
   be great, because in this instance they would not apply to what I’m using the
   plugin for.
 * 2. Also, I can’t remember if it supports Post Thumbnails(‘Featured Images’) in
   the output of each related post? I managed to get a friend to hack the ability
   in but it would be great if it was built in or better documented.
 *  [Justin Tadlock](https://wordpress.org/support/users/greenshady/)
 * (@greenshady)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/custom-post-types-and-plugins/#post-1549266)
 * I’m not going to go looking through other people’s plugins, but the basic idea
   only takes three lines of code:
 *     ```
       $post_types = get_post_types( array( 'public' => true, 'exclude_from_search' => false ), 'objects' );
   
       foreach ( $post_types as $type )
       	add_meta_box();
       ```
   
 * Rather than the plugin registering the meta box for just pages or just posts,
   it could loop through the available post types and register its meta box.
 *  [dgwordpressuser](https://wordpress.org/support/users/dgwordpressuser/)
 * (@dgwordpressuser)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/custom-post-types-and-plugins/#post-1549293)
 * Firstly, thank you Microkid for a great plugin. I hope you dont mind me posting
   this fix for CPT and perhaps you could use it to update the next version 🙂
 * whipd09, I have found a hack to satisfy your #1 request until it makes it into
   the plug-in.
    In the microkids-related-posts.php I changed the following:
 * 1. change: function MRP_add_custom_box() {
    add_meta_box( ‘MRP_sectionid’, __(‘
   Related Posts’, ‘MRP_textdomain’ ), ‘MRP_inner_custom_box’, ‘post’, ‘normal’ );//
   remove this line if you dontwant it to show in normal posts add_meta_box( ‘MRP_sectionid’,
   __( ‘Related Posts’, ‘MRP_textdomain’ ), ‘MRP_inner_custom_box’, ‘archives’, ‘
   normal’ );//change archives to the name of your custom post type. You could also
   add more types by copying this line for each type.
 * 2.function MRP_inner_custom_box() {
    change: if( $related_post->post_type == ‘
   page’ ) { to if( $related_post->post_type == ‘archive’ ) {
 * 3. change $post_title = “[Page] ” . $post_title; to $post_title = “[Archive] ”.
   $post_title;
 * 4. function MRP_save_postdata( $post_id ) {
 * change: if ( ‘page’ == $_POST[‘post_type’] ) { to if ( ‘archives’ == $_POST[‘
   post_type’] ) {
 * 5. function MRP_auto_related_posts( $content ) {
    if( get_post_type() == ‘page’){
   to if( get_post_type() == ‘archives’ ) {
 * Lastly in mrp-search.php, change:
    $query = “SELECT ID, post_title, post_type,
   post_status FROM $wpdb->posts WHERE $where AND ( post_type = ‘archives’ OR post_type
   = ‘page’ ) “; to your post type.
 * Hope it helps someone.
 * Edit: I also added this into admin_init() function in my custom functions file
   when registering the CPT: add_meta_box( ‘MRP_sectionid’, __( ‘Related Links’,‘
   MRP_textdomain’ ), ‘MRP_inner_custom_box’, ‘archives’, ‘normal’ );
 *  [microkid](https://wordpress.org/support/users/microkid/)
 * (@microkid)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/custom-post-types-and-plugins/#post-1549306)
 * Hi whipd09,
 * I have just released version 3.0 of my plugin. Apart from a bunch of other cool
   new features, this version also adds support for custom post types. You can update
   it through your WordPress admin or read more about the new version on the [Microkids Related Posts plugin website](http://www.microkid.net/wordpress/microkids-related-posts-version-3-0/)
 * Check it out and let me know what you think!

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

The topic ‘Custom Post Types and Plugins’ is closed to new replies.

## Tags

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

 * 9 replies
 * 6 participants
 * Last reply from: [microkid](https://wordpress.org/support/users/microkid/)
 * Last activity: [15 years, 9 months ago](https://wordpress.org/support/topic/custom-post-types-and-plugins/#post-1549306)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
