[resolved] How to insert new categories into database from a plugin (2 posts)

  1. narken
    Posted 7 years ago #


    Im trying to make a new pluing that automatically makes a post everyday with weather information from around the world.

    Every works fine except I would like to also create new categories from within the plugin either by a wp function or directly into the database. Sometimes the category might already be there sometimes not and I would then have to create it.

    Is there a function to add a category or do I have to put it directly into the database ?

  2. yakuphan
    Posted 7 years ago #

    There is a function to add category in wp-admin\taxonomy.php and it is called from wp-admin/categories.php
    The function: wp_insert_category($_POST)
    Look at Categories in Dashboard and learn which variable to POST. You can find them in Add Category Form by looking source code of this page.
    (Sorry, for my poor English)

Topic Closed

This topic has been closed to new replies.

About this Topic