@10up/cypress-wp-utils
    Preparing search index...

    Function createTerm

    • Create a Term of a given taxonomy

      Parameters

      • name: string = 'Test category'

        Term name

      • taxonomy: string = 'category'

        Taxonomy

      • options: {
            beforeSave?: CallableFunction;
            description?: string;
            parent?: string | number;
            slug?: string;
        } = {}

        { slug - Taxonomy slug parent - Parent taxonomy (ID or name) description - Taxonomy description beforeSave - Callable function hook }

      Returns void

      Create new category with default name "Test category"

      cy.createTerm()
      

      Create new category with given name

      cy.createTerm('Category')
      

      Create a category and use it's ID

      cy.createTerm('Category').then(term => {
      cy.log(term.term_id);
      });

      Create new term in a product taxonomy

      cy.createTerm('Product name', 'product')
      

      Create child category for existing Parent with custom description and slug

      cy.createTerm('Child', 'category', {
      parent: 'Parent',
      slug: 'child-slug',
      description: 'Custom description'
      })