WordPress.org

Forums

Media Category Library
[resolved] Add Media Category via PHP CODE (2 posts)

  1. XPOL555
    Member
    Posted 1 year ago #

    Hi all,
    This plugin is really grates and helped me a lot!
    I've done a custom function to list the medias category depending of the current logged user:

    <?php function comm_list_usr(){
        $current_user = wp_get_current_user();
    	echo '[mediacat cats='.$current_user->user_login.' orderby="date" order="DESC"]';
    	} ?>

    This function is executed in a single specific page.
    Now i've to do that when one new user is registered it creates the category with same name of the user...

    The question is:
    Is there a function to create a new media category via PHP?

    Thanks!

    https://wordpress.org/plugins/media-category-library/

  2. timmcdaniels
    Member
    Plugin Author

    Posted 11 months ago #

    Hi,

    Using the default media category taxonomy, you could do something like this:

    wp_insert_term( 'New Category Here', 'media-category' );

    Thanks,

    Tim

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Media Category Library
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic