WordPress.org

Ready to get started?Download WordPress

Forums

Attachments
[resolved] Can't add to custom post types (9 posts)

  1. jjust1
    Member
    Posted 1 year ago #

    Disable default
    define( 'ATTACHMENTS_DEFAULT_INSTANCE', false );
    doesn't work.

    When I enter a custom instance, I get 2 attachment boxes on posts and pages but nothing on my custom post types.

    Please help. I'm on WP 3.5.

    http://wordpress.org/extend/plugins/attachments/

  2. Jonathan Christopher
    Member
    Plugin Author

    Posted 1 year ago #

    Please make sure you add that line ABOVE this line in wp-config.php:

    /* That's all, stop editing! Happy blogging. */

    Adding it below that line means it's too late to take effect.

  3. Naldo
    Member
    Posted 1 year ago #

    Great plugin Jonathan! But like jjust1, I display 2 attachment boxes on the included post types (ie posts) but nothing on my custom post type admin pages.

    Added the constant to the wp-config like you mentioned and that removed 1 of the boxes but still didnt add any attachment box to my custom post type page.

    Any ideas? I am using WP 3.5 and Attachments (latest ver.)

  4. herrkris
    Member
    Posted 1 year ago #

    I think the documentation isn't quite clear on this topic, but, if you want to use the plugin with custom post types, you have to create a custom instance as described in the documentation. You can copy pase it and just modify the array entry 'post_type' so it contains your custom post type. Well, on second though it seems clear enough :D

    Hope I'm not mistaken, but at least it works for me :)

  5. Jonathan Christopher
    Member
    Plugin Author

    Posted 1 year ago #

    naldope: did you follow the instructions here? Can you paste what you've added and where? Also include the CPT name you're trying to target.

    herrkris: Documentation improvement suggestions are more than welcome, I've done the best I can in trying to explain things but in my experience it's more about people not wanting to read the documentation than actually following it. What is it you feel is confusing about the usage docs? I've done my best to recreate the nicer GitHub docs into the plugin page on .org, but I'm limited by the readme.txt requirements and lack of styling there.

  6. herrkris
    Member
    Posted 1 year ago #

    Hey Jonathan, sorry for the confusion, the only thing that wasn't quite clear to me -- and yes you're correct with "people not wanting to read the documentation" -- that I have to add a custom post type. After reading the documentation and the code example everything was pretty clear to me.

    Perhaps you can add a little note to the usage section. If you want to use the plugin with a custom post type you have to create a custom instance and change the value for the post_type. I think when you quick scan the documentation you tend to skip the code block and wonder why the plugin isn't working with the custom post type. :)

  7. Naldo
    Member
    Posted 1 year ago #

    herrkris: OMG! That did it! Thank you.

    jonathan: I think I was focused on the line to add my instance:
    $attachments->register( 'my_attachments', $args ); // unique instance name

    instead of adding my CPT here:

    // all post types to utilize (string|array)
        'post_type'     => array( 'post', 'page' ),

    Maybe place a comment right next to there saying // insert your custom CPT here, if needed

    Thank you both so much!

  8. Jonathan Christopher
    Member
    Plugin Author

    Posted 1 year ago #

    herrkris: Great feedback, thank you! I'll get something added in an upcoming release for sure.

    Naldo: Gotcha, thank you as well, I'll spend some time making the docs more obvious as soon as I can.

  9. Jonathan Christopher
    Member
    Plugin Author

    Posted 1 year ago #

    The docs have been updated to be a bit more explicit about needing to customize an instance to work with Custom Post Types. Thanks again for the feedback!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic