I am not sure how you are activating theme on Network but here I am considering a case of installing fresh theme on a existing Network.
Activating theme on any single site will insert the term for every site in Network but yes of course taxonomy registration code should be there already.
Consider this example
function after_switch_theme_callback() {
$blogs = wp_get_sites(); //Array of site Ids
foreach ($blogs as $blog) {
if (!empty($blog['blog_id'])) {
switch_to_blog($blog['blog_id']);
wp_insert_term('myTerm '.$blog['blog_id'], 'genre');
restore_current_blog();
}
}
}
add_action('after_switch_theme', 'after_switch_theme_callback');
It seems to me working fine.
Note:
Register your taxonomy on
init
action so later terms can be inserted
onafter_switch_theme
action.
Related Posts:
- install.php Custom Taxonomy Term not being added to custom post
- Get Posts by Custom Post Type ,Taxonomy, and Term
- Get The Post Type A Taxonomy Is Attached To
- Display current taxonomy term when inside custom post type
- Get term slug of current post
- How to limit the number of terms (terms acts like categories)
- How do I list custom taxonomy terms without the links?
- wp_insert_term doesn’t work with custom post type’s taxonomy
- Multisite wide post type?
- wp_get_object_terms(): count relative to passed IDs?
- Count posts that have specific taxonomy term attached
- display multiple term post from taxonomy in a single page
- Maintaining strict one-to-one association between terms and custom posts
- If on term-page -> get the current term?
- Adding a term name from a custom taxonomy assigned to a post link displayed by a wp_query loop based on another taxonomy
- Querying Posts by Taxonomy From Alternate Network Site
- WPMU: Programmatically adding CPT posts to specific blog id
- Get all taxonomies for all post types
- How do I provide a “show all posts” link in a paginated term archive?
- Rewrite Custom Post Type URL slug
- Multisite Global Custom Posts
- Multisite custom post type’s single page 404
- How to output wordpress custom tags separated by comma?
- Does WordPress limit the length of slug names for Post Meta or Terms?
- Custom Taxonomy Invalid in REST API
- get_post_meta returns empty array for terms
- Custom Post Type Archive Page Filtering
- Get template part using a custom taxonomy term
- Get posts by querying taxonomy and certain terms of the taxonomy?
- How to restrict users and admin from creating new taxonomy terms?
- How to set up multisite for multi language?
- How to build custom route by adding taxonomies to URL ? ex: www.demo.com/communities/palo-alto/
- Post count by month of taxonmy term
- How do I display the taxonomy for a custom post type in an array
- WPMU: Cross site custom post type
- How to include term custom meta into the custom taxonomy term permalink structure
- Setup template_redirect using has_term when NO term assigned
- Custom while loop for hierarchical display of a taxonomy
- Lists custom taxonomy terms that has specific custom field value assigned to the term (not post)
- Display taxonomy terms, child terms and posts in a template
- Use custom walker to add taxonomy terms to main nav menu
- Multisite: How to define and limit a Custom Post Type to specific sites?
- Add term to custom post type on draft
- Listing all term items alphabetically / sorting loop
- How to get WordPress term attached to the Post?
- Output terms for custom post types
- How to add terms (without deleting others)
- Get parent category id from child category page for custom taxonomy
- How to get only child terms from a custom taxonomy of current post type?
- Custom Post Types Archives and Single Pages not showing custom taxonomy data
- Get terms of a post but only if they’re also the child of a specific term
- The Difference Between Categories and Tags and Taxonomies and Terms
- How to display custom taxonomy term meta on custom post type
- Is there SEO or related limitations to using Custom Post Types instead of WPMU?
- posttype and custom fields on multisite
- Default post_tag for custom post type
- Commas not displaying in implode
- does wp_insert_term link the term to a certain post ID?
- Grab all Custom Posts by multiple taxonomies and terms
- Using get_terms() to list terms from one custom taxonomy AND from one specific built-in category
- Query for specific taxonomy that executes a particular loop depending on volume of posts?
- Two-way synchronizing of a post type among multisite blogs
- Order posts by taxonomy terms
- automatically select taxonomy based on post meta
- How to display custom taxonomy term specific post?
- How to associate custom taxonomy terms with custom post type?
- get_queried_object not work in taxonomy page
- Custom Post type not Querying in switch_to_blog loop
- Change the term based on the value of a $variable using wp_update_post in submitting a form
- get_the_terms child terms for current post/custom post only
- Prev / Next Post Same taxonomy Custom Post Type
- Dropwdown: Get taxonomy terms from posts that share preselected terms from 3 other taxonomies
- Custom Post Type / Taxonomy / Term – what template to use to avoid 404-page?
- Pages of my taxonomy terms are showing all posts
- Display title of all custom posts from same taxonomy term on a custom post template
- wordpress does not see the correct custom taxonomy hierarchy
- Get category list & taxonomy list from different post type using post id?
- How to get all posts related to a taxonomy?
- Custom taxonomy- only output relevant terms
- Displaying the Taxonomy and a Queried Term on a taxonomy.php page?
- WordPress add taxonomies/terms list as a menu in archive page
- Hide Custom Taxonomy title if not associated with another Custom Taxomony
- How to pass taxonomy terms to WP_Query along with $args?
- Custom Post Status & Taxonomies
- Shared Custom post type between WP network sites
- Create an additional template page for every term taxonomy
- Prevent repetitive terms in get_the_term_list
- Issue on Counting CPT’s Under Taxonomy Term
- Taxonomy Grid Archive Help?
- Custom post type URL returns 404 error page
- List a custom post type’s posts ordered by nested custom taxonomy
- How to add a post counter to the list of custom taxonomy terms?
- Author template – separate custom post type by custom taxonomy term for $curauth
- Navigation links to posts in current term shortcode
- Display associated taxonomy child name on single CPT page
- How to manage a bookstore
- Get all terms assigned to a post from different taxonomies
- Create WP multisites as a custom post type
- Get term link of shared taxonomy between multiple post types
- WordPress Multisite Network Shared Custom Post from Main Site using single-CPT.php