• Resolved @PhilipHoy

    (@venomphil)


    Hi Enhanced media library

    I’d like to use your plugin to sort out my media library – currently users submit documents via a front end form and they are sorted in the standard WordPress media library (its a mess!). If there a way to programmatically assign a category to this document?

    If so how?

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author webbistro

    (@webbistro)

    Hi @venomphil,

    Enhanced Media Library registers a taxonomy Media Categories and you can add any other custom taxonomy with its UI. It uses register_taxionomy core function. So, you can use wp_set_object_terms to set a specific taxonomy term(s) to an attachment.

    Best,
    -Nadia

    Thread Starter @PhilipHoy

    (@venomphil)

    Thanks for the feedback, programatically how would you set a term with your plugin?

    Guessing something like

    wp_set_object_terms(image ID, category name, ‘media_category’);

    • This reply was modified 7 years, 9 months ago by @PhilipHoy.
    • This reply was modified 7 years, 9 months ago by @PhilipHoy.
    Plugin Author webbistro

    (@webbistro)

    Hi @venomphil,

    The example:

        $term_ids = array( 14, 19 );  // media category IDs
        $taxonomy = 'media_category'; // or any other media taxonomy name
        
        wp_set_object_terms( $attachment_ID, $term_ids, $taxonomy, false );

    You can read more about wp_set_object_terms here https://codex.wordpress.org/Function_Reference/wp_set_object_terms

    Best,
    -Nadia

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

The topic ‘Programmatically assign category’ is closed to new replies.