What you need is switch_to_blog and maybe get_blog_id_from_url which you would use like this:
$blog_id = get_blog_id_from_url( 'www.example.com' );
switch_to_blog( $blog_id );
wp_create_category( 'mycategory', 0 );
restore_current_blog();
Related Posts:
- WordPress Multisite – global categories
- Get posts from sites in Multisite?
- Multisite – Protect categories from deletion?
- Category page doesn’t use category.php, instead it redirects to homepage
- 5 blogs on one WordPress site
- Multisite blog converting categories to subdomains
- Adding categories to all blogs at once
- WordPress MU 2.9.2 to 3.0.5 changes to category.php
- How to make category RSS feeds show full content
- Multi-site or categories?
- WordPress Multisite – global categories
- Default category link for a custom category is a broken link
- Archives for each category on WP Multisite
- How do I share categories across selected sites in a Multisite setup
- get_categories() returns “Uncategorised”
- wordpress multisite… collect all posts on main blog – exclude category?
- Can Categories be used to hack a Multisite-like setup w/ a single MySql db?
- How to Sync Menu, Widgets and other masters from Main Website to its Sub Site
- Categories show 404 error on multisite installation
- Global navigation in multisite: problem with categories
- Duplicate new categories across multisite network
- get_the_category return empty inside loop
- global categories – Share specific categories in wordpress multisite
- Limit Category/Tag Dropdown To blog_id in Multisite Install With Global Categories/Tags
- Using template file for single post in sub-directory multisite
- A search box for all sites – Multisite
- How to create default categories in new installs?
- Multiple parent categories
- How to populate a WordPress install with a lot of categories, quickly?
- How to structure Multisite sites into categories?
- Activate Gutenberg in category-descriptions
- How to show subcategories in categories else show posts
- How would I increase the Author Role to be able to add a new category?
- How to remove the parentheses from the category widget
- Only show category to certain user levels without plugin
- How to: 301 Redirect /category/ to /customname/
- Custom Query to search through categories
- Get sticky post from category?
- Display one latest post from multiple categories
- Archive pagination causing 404 with permalinks structure
- Get a list of Terms for a specific category
- Remove Archive Headline and Archive Intro Text fields on category and tag archive pages in WordPress Admin with Genesis framework
- How Do I Merge Categories With phpMyAdmin
- Display name of the last child category
- How do I specify more than one category?
- Set the default category of an attachment
- exclude post from displaying in loop if it is in a category, but not in many categories
- Set post categories to include parents when setting child category
- Making a tourism information website [closed]
- Adding Categories Through Function
- WordPress search only showing a few posts
- How to recreate a copy of a product category in WooCommerce? [closed]
- Multiple category archive page
- List subcategories of active parent category (WooCommerce)
- How to display post type and category links in foreach WordPress code
- Updating category template to change how subcategories display
- Add multiple classes. Different style for each category tag
- Inside a loop, how to change CSS class based on category name?
- Add a custom category page in WordPress.org
- Remove the parent name from permalink
- Make parent category an optgroup
- Randomly load categories with latest post
- Is it possible to remove from default category widget?
- WordPress alphabetical A-Z custom post type post result display
- Count category views – Is it possible?
- wp_dropdown_categories not showing option as selected
- How to check if a post belongs to a category that has only 1 posts?
- How do I use just one category’ posts on my home page?
- If x comments in a post move post to category y
- Count tags for a specific category
- wp_list_categories walker without links on categories that have subcategories (to make a nested dropdown menu)
- How can I display tags as categories?
- Adding additional content on post depending on post categories
- Set category page title in custom theme [closed]
- wp_list_categories not excluing multiple ids
- Custom meta boxes ID prefix showing on first category but not others
- Exclude category from foreach loop
- ID of last created category
- Get categories of queried posts
- Limit Loop to One Category
- wordpress taxonomy query posts
- Different header for each category
- sidebar troubles, taxonomy trouble
- Code for Category, Tags, Archive URLs
- Display all subcategories from parent category
- Custom Loop with certain number of one category
- How to show WooCommerce Categories on ‘shop’ page instead of products?
- How to list all subcategories from all categories but not from a certain category
- How to create Child Category page from scratch at wordpress?
- Automatically create tags and merge with categories
- How to insert category to post via php?
- Show Subcategory Name Instead of Parent Category
- Get category id of next / prev post inside the_post_navigation
- Media Library filter returns undefined function get_current_screen
- Custom built theme won’t filter categories
- WP_query exclude a category unless it has more than one catagory
- get IDs from links categories
- Narrow Down a Shop Page Results Based on a Product Tag in WooCommerce
- How to control order when displaying child categories
- CPT Custom post type Tags & Categories not showing for ‘Editor’ user in editor