WordPress.org

Ready to get started?Download WordPress

Forums

Attachments
[resolved] Attachments not showing for custom post type editing (13 posts)

  1. timothylang
    Member
    Posted 1 year ago #

    I have a similar issue others have had with the attachments pane not showing up in the add/edit post for a custom post type, but with the difference that I never had the legacy version installed. I had WordPress 3.3.1 and Attachments 3.4.2.1, and my attachment pane was showing up fine for posts, pages and my custom type "resources". Then I upgraded to WordPress 3.5.1 and Attachments 3.5, and now the attachments pane only shows up for post and page adding/editing. It won't show up in the editor, and the posts I had added that included attachments no longer showed their attachments on the site. I tried downgrading the plugin back to 3.4.2.1 but it made no difference.

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

  2. Jonathan Christopher
    Member
    Plugin Author

    Posted 1 year ago #

    Did you run the migration script and check out the documentation for all the changes in Attachments 3.0+ from the legacy version?

    Edit sorry just re-read your post and you didn't need to migrate. Can you elaborate on where its showing up vs. not showing up? I'm a bit unclear on that.

  3. timothylang
    Member
    Posted 1 year ago #

    I created a custom post type called "resources" using the Custom Post Type UI plugin. After upgrading, when I try to add or edit a resource the My Attachments panel does not show up in the admin. But the panel is still there for both posts and pages. Also the attachments I had attached to my resources before upgrading are no longer showing up on the public site.

  4. Jonathan Christopher
    Member
    Plugin Author

    Posted 1 year ago #

    Are you using the default instance or did you create your own? If you're using the default instance it only supports Posts/Pages out of the box and you'll need to create a custom instance. If you're using a custom instance you'll need to add resources to your post_type argument.

    If you've been using Attachments and want to continue using the same instance as you're using on your Posts/Pages, just name it attachments as per the docs and it will overwrite the default instance and you can keep using all of that data.

  5. timothylang
    Member
    Posted 1 year ago #

    That was it! For some reason the attachments panel previously showed up for my custom post type even though I had not specified it to do so in the custom instance. When I added it to the array in $args it showed up right away. I should've been paying more attention to the $args variable. Thanks so much!

  6. Jonathan Christopher
    Member
    Plugin Author

    Posted 1 year ago #

    That's strange it was showing up without having specified it, if you by chance find that happening again if you could shoot me a note that'd be much appreciated (in case it's a bug somewhere)—either way, glad you're sorted out, enjoy the plugin! If you've got a spare minute a Review is much appreciated.

  7. defdumbandblind
    Member
    Posted 9 months ago #

    Hi Jonathan! I have been working on a site for someone and ran into this exact issue. I have identified that the issue lies in the fact that whoever built this site, set up a multitude of custom page types and as a result, the 'Attachments' meta box doesn't show when editing these.

    I have read the doc on setting up a custom instance, but I find myself scratching my head still, although the GitHub instructions seems extremely well written. How can I add this already working Attachments function on pages that have been customized, outside of the normal WordPress Posts/Pages? I know I modify the functions.php file, but how do I point this code in functions.php, and instruct it to display oh these custom pages?

    I hope this makes sense, I am just seeing no results by simply copying the code and leaving it at that. Do I need to customize the php arrays?

    Thanks in advance and keep up the great work!

  8. defdumbandblind
    Member
    Posted 9 months ago #

    To try and be even more specific. The font end DOES display images that were attached using this feature in the past. The issue is that when editing one of these custom pages, the option or meta box 'Attachments' isn't showing up anywhere. The images on the site are still there. I'm also seeing that in the theme files, there is a document called attachments.php, which I can only assume is there to forgo editing functions.php. Would I be right in this assumption?

  9. Jonathan Christopher
    Member
    Plugin Author

    Posted 9 months ago #

    Hi there, it sounds like the active theme or another plugin is interfering along the way at some point. The best way to see if that's the case is to deactivate all plugins except Attachments and switch to the default WordPress theme to see if Attachments shows up on your edit screens as expected. If it does, you can start by activating your theme to see if it triggers the issue. If not, you can activate plugins one by one to see what the culprit might be. If this approach still yields a problem with Attachments we can troubleshoot a bit further.

  10. defdumbandblind
    Member
    Posted 9 months ago #

    Thanks a lot for the reply. I disabled all my plugins, exception Attachments. Refreshed my custom page in edit mode, but saw no Attachments meta box. Without reinstating plugins, I changed the theme back to the default WP theme, but of course, with it goes my Custom Pages, so I couldn't get to the issue at hand with this technique.

    So, I'm still here. The problem only seems to be in the Attachments option not showing up for my Custom Pages.

    Thanks again.

  11. defdumbandblind
    Member
    Posted 8 months ago #

    I'm still struggling to get any of the Attachments working on my custom pages. Anybody have any other suggestions or thoughts that I might try out?

    Thanks.

  12. defdumbandblind
    Member
    Posted 8 months ago #

    Resolved. For all of those future Attachments user who struggle with this same issue, try this...

    Force the legacy version in your wp-config.php file, putting this in at the TOP, not the BOTTOM:

    define( 'ATTACHMENTS_LEGACY', true ); // force the legacy version of Attachments

    I tried so many different things and in the end, it was a matter of putting this at the top instead of at the very end of the document. Now my attachments feature appears on every post and page, custom or default.

    Hope that helps.

  13. phatelvis
    Member
    Posted 7 months ago #

    I could not get the attachments meta box to appear for my custom post type, when adding new: my-publication

    I discovered that I had to edit line 1225 of

    attachments/classes/class.attachments.php

    changing

    $post_type = str_replace( '-', '_', sanitize_title( $_GET['post_type'] ) );

    to

    $post_type = str_replace( '_', '-', sanitize_title( $_GET['post_type'] ) );

    As far as I can see, a post type can be registered containing either a "-" or a "_", so maybe the str_replace is superfluous??

    "$post_type
    (string) (required) Post type. (max. 20 characters, can not contain capital letters or spaces) "

    http://codex.wordpress.org/Function_Reference/register_post_type

    Either way, that aside, this is a very useful plugin, thanks

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic