BuddyDev

Search

Categories for media

  • Participant
    Level: Master
    Posts: 413
    Venutius on #12887

    Hi Brajesh,

    I seem to have a growing need to categorise media items in order to make them easier to find and display in lists. For example one site I look after is for a music group, every week they upload audio items, they’ve been complaining that galleries quickly become cumbersome as they become unwieldy what there’s to many audio files in there, but creating another gallery simply means they have two (or twenty) galleries to scroll through when looking for specific “takes” of a particular track. It occurred to me that if we could assign each media item into categories then searching for specific items would be uch improved.

    Is it possible to assign a taxonomy to individual media items?

  • Participant
    Level: Master
    Posts: 413
    Venutius on #12888

    Sorted – just assign a taxonomy to attachments

  • Participant
    Level: Master
    Posts: 413
    Venutius on #12889

    Ah, it’s not that simple it seems. I assigned a custom taxonomy to attachments and assigned taxonomy terms to each of the audio files. I have a taxonomy sidebar widget which is displaying the taxonomies but clicking on them just returns a page not found error.

    I also assigned the default categories to attachments but whilst the items appear in the categories list, clicking on them just returns a heading of the term with no content.

    I think I need a template page to display the attachments (attachments.php or similar) but I’m lost as to what to add into this to display (1) the list of attachment category items, and (2) the single attachment view.

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #12899

    Hi George,
    attachment are post type that have the post_status set to publish.

    For your taxonomy archive page, you will need to add this posts status too in the WP_Query(using pre_get_posts). Otherwise, it won’t list attachments.

    Hope that helps.

    Regards
    Brajesh

  • Participant
    Level: Master
    Posts: 413
    Venutius on #12906

    Hi brajesh,

    Thanks for the tip, it’s now finding the category lookup. However I’d really like to get my custom taxonomy ‘music’ to work. right now it is coming up with a not found error – looking for the page http://www.site.com/music/track I thought this might be because I don’t have a music.php template so I created on but unfortunately that’s not working, any ideas?

  • Participant
    Level: Master
    Posts: 413
    Venutius on #12907

    One of the reasons why I’d rather not use category as the taxonomy for audio items is that the band already use category for their blobs, so I have to show the category widget in the sidebar and unfortunately adding category to audio items causes them to be displayed to the public, clicking on them allows any not logged in user to be able to play these “group only” files.

  • Participant
    Level: Master
    Posts: 413
    Venutius on #12908

    If I have them on a custom taxonomy I can set up a different taxonomy widget and hide that from the public

  • Participant
    Level: Master
    Posts: 413
    Venutius on #12909

    Actually, what I did seems to have broken all the security for the site, the bands private audio files started showing up in a lot of listings that the public can see, here’s the code I added, is it wrong?

    function wpmt_search_filter($query) {
    if ($query->is_search() && $query->is_main_query() || is_archive() )  {
    $query->set('post_status', array( 'publish', 'inherit' ));
    $query->set( 'post_type', array( 'post', 'attachment' ) );
    }
    return $query;
    }
    
    add_filter('pre_get_posts','wpmt_search_filter');
  • Participant
    Level: Master
    Posts: 413
    Venutius on #12910

    I tried changing is_search() to is_archive() but this caused all the private music files to be publicly visible.

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #12920

    Hi George,
    I am sorry I had left early yesterday and was not able to assist.

    There are a few things I will need to know:-
    1. How are you enforcing the privacy?
    2. What is the name of the taxonomy that you are using.
    3. Are you using the same taxonomy for attachment and other post types too?

    Please let me know and I will assist.

    Thank you
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved