WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. XPOL555
    Member
    Posted 6 months 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 2 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

Reply

You must log in to post.

About this Plugin

About this Topic