WordPress.org

Ready to get started?Download WordPress

Forums

Media Tags
[v3.0.5] [Bug] retrieving posts for custom post types (4 posts)

  1. drebabels
    Member
    Posted 1 year ago #

    In our deployment we have created a new post type for Videos and have used the media-tags taxonomy to add tags to the videos.

    However, when attempting to retrieve videos by media-tags nothing was being returned. After investigating this issue, it looks to be caused by the post_type being hardcoded to 'attachment' rather than respecting what what passed in through the get_attachments_by_media_tags function.

    The offending line can be found around line 323. The original code looks like

    $get_post_args['post_type'] = 'attachment';

    The fixed code should look something like

    $get_post_args['post_type'] = $r['post_type'] ? $r['post_type'] : 'attachment';

    so that 'attachment' is specified for the post_type only if the post_type is empty.

    http://wordpress.org/extend/plugins/media-tags/

  2. Paul Menard
    Member
    Plugin Author

    Posted 1 year ago #

    I have to disagree how you are using my plugin. The intention of the plugin was to associate tags to the post type 'attachment'. All media, image, documents, pdf, mo3, movies are stored into WordPress with post_type 'attachment'. The plugin was NOT intended to have media-tag associated with other post types.

    Remember in WordPress there is a specific parent-child relationship between the attachment and parent. The parent can be any post type: post, page, or some custom post type. When you use the media-tag template functions they are intended to work with attachments only.

  3. drebabels
    Member
    Posted 1 year ago #

    I see where you are coming from, and if I understand you correctly what you are doing is allowing people to specify the retrieval of all attachments with a specific tag that is also attached to a specific post_type (i.e. 'post' or 'page' or 'custom post type'). But I wonder if people have actually needed that sort of specificity?

    In my experience this has not been necessary. What I am more interested in is retrieving all 'media' content that has been tagged a certain way, regardless of what post_type it has been attached to.

    Now I realize that you said that this was not how this plugin was intended to be used, but using media-tags taxonomy on other post types seems to me to be well within how WordPress treats taxonomies. The built in taxonomy 'tags' is used on both 'page' and 'post' post types. And in my experience it has worked flawlessly so far (except for the issue that I am writing to you about now). So in my opinion it would be a mistake to limit the plugin to only being able to retrieve attachments.

    Perhaps then the answer is not to change the get_attachments_by_media_tags because it does do exactly what it was designed to do but rather to add a new function 'get_posts_by_media_tags' that would not assume that the content I am retrieving is an attachment.

    Thoughts?

  4. Paul Menard
    Member
    Plugin Author

    Posted 1 year ago #

    drebabels,

    Sorry for my late reply. Have been traveling.

    I see where you are coming from, and if I understand you correctly what you are doing is allowing people to specify the retrieval of all attachments with a specific tag that is also attached to a specific post_type (i.e. 'post' or 'page' or 'custom post type'). But I wonder if people have actually needed that sort of specificity?

    No, you are not understanding. What Media-Tags does is allow the user to tag the media items. Media items are always of post type 'attachment'. This is per WordPress core functionality. And post_type 'attachment' items are always associated with a parent post type like Post, Page, custom post type. So when someone uses the Media-Tags template functions to query all the attachments tagged a certain way it is the same as you showing all Posts in a specific tag. But this is specific to the attachment post type.

    See WordPress treats attachments different than Post, Page or some custom post type. If you were to register a new taxonomy 'Events' and associate it with Posts you would see the new menu item show under the Posts menu section.

    But for attachments this does not function the same. If you register a taxonomy and associate it with the 'attachment' post type you will not see a new menu under the Media section. And what you will see on the Media item form is a simple input field where you can enter something.

    So what Media-Tags does is provide an interface where the user can tag Media items (post_type = attachment) is a familiar manor. Again this is specific to the attachment post_type.

    From what I see you writing you want to associate Media-tags with all post types Posts, Page, whatever, You wouldn't do this with the post tag or category taxonomies.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic