0

I have a custom post type set up on a subsite in a multisite network which the code is in a plugin to activate it only for the subsite.

I have some code that inserts a post using code but I belive it is trying to insert it into the main site. it is simply a php page with

require( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' );

then some $_POST to grab some data and use that to create a post. This works fine in a standalone install of WordPress but on the multisite it does not work. Is there a way to choose the site to add the post to?

1 Answer 1

1

You probably need to switch your context to the subsite in which the posts need to be created. Have a look at the switch_to_blog() and restore_current() functions in wp-includes/ms-blogs.php See http://phpxref.ftwr.co.uk/wordpress/wp-includes/ms-blogs.php.source.html#l437

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.