Title: Problem with posts generated via wp_insert_post in multisite
Last modified: July 8, 2025

---

# Problem with posts generated via wp_insert_post in multisite

 *  Resolved [duttoluca](https://wordpress.org/support/users/duttoluca/)
 * (@duttoluca)
 * [9 months, 2 weeks ago](https://wordpress.org/support/topic/problem-with-post-generated-via-wp_insert_post-in-multisite/)
 * Hello, I have a multisite with several blogs.
   In one of those blog (let’s call
   it blog_x), where WP Telegram is not enabled, I have a function that retrieves
   some data every night (using the scheduler in wp) and create posts using wp_insert_post.
 * In other blogs (blog_y for example) I have WP Telegram installed and configured
   with autopost.
 * My problem is: when the nightly task in blog_x runs and the new posts are created,
   they are sent via Telegram in the blog_y channel.
   The posts are correctly created
   in blog_x, no reference to blog_y and such, everything is fine, but then are 
   fired by a different blog/channel.
 * I have the logs from your plugin, if they could help…
 * Any help? 
   Thanks
    -  This topic was modified 9 months, 2 weeks ago by [duttoluca](https://wordpress.org/support/users/duttoluca/).
    -  This topic was modified 9 months, 2 weeks ago by [duttoluca](https://wordpress.org/support/users/duttoluca/).

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [Irshad Ahmad](https://wordpress.org/support/users/irshadahmad21/)
 * (@irshadahmad21)
 * [9 months, 2 weeks ago](https://wordpress.org/support/topic/problem-with-post-generated-via-wp_insert_post-in-multisite/#post-18547863)
 * Thank you for reaching out. This seems to be an interesting problem to solve.
 * > I have the logs from your plugin, if they could help…
 * Yes, please share those with our support on Telegram – [@WPTelegramSupport](https://t.me/WPTelegramSupport).
 * Once we check the logs, we will get back to you here on the public forum.
 *  Thread Starter [duttoluca](https://wordpress.org/support/users/duttoluca/)
 * (@duttoluca)
 * [9 months, 2 weeks ago](https://wordpress.org/support/topic/problem-with-post-generated-via-wp_insert_post-in-multisite/#post-18547939)
 * Hi [@irshadahmad21](https://wordpress.org/support/users/irshadahmad21/) . My 
   colleague sent logs and infos to your support channel on Telegram, thank you 
   very much for your help.
 *  Plugin Author [Irshad Ahmad](https://wordpress.org/support/users/irshadahmad21/)
 * (@irshadahmad21)
 * [9 months, 1 week ago](https://wordpress.org/support/topic/problem-with-post-generated-via-wp_insert_post-in-multisite/#post-18556080)
 * Hello,
 * It seems like something is wrong with the cron system on your multisite install.
 * Can you please sent the delay in posting in Post to Telegram settings to `0` 
   and then try again to see if it still posts on the wrong site?
 *  Thread Starter [duttoluca](https://wordpress.org/support/users/duttoluca/)
 * (@duttoluca)
 * [9 months, 1 week ago](https://wordpress.org/support/topic/problem-with-post-generated-via-wp_insert_post-in-multisite/#post-18556109)
 * Hi [@irshadahmad21](https://wordpress.org/support/users/irshadahmad21/)
 * Delay is already set to 0 wherever the wp telegram plugin is enabled.
 * As a temporary workaround we disabled everywhere the “autopost on new article”
   flag, and it worked…
   But we’d like to enable it again.
 * If you have any suggestion, or need more infos (logs, code…) let me know
 *  Plugin Author [Irshad Ahmad](https://wordpress.org/support/users/irshadahmad21/)
 * (@irshadahmad21)
 * [9 months, 1 week ago](https://wordpress.org/support/topic/problem-with-post-generated-via-wp_insert_post-in-multisite/#post-18556129)
 * Does your code correctly use [switch_to_blog](https://developer.wordpress.org/reference/functions/switch_to_blog/)
   when using `wp_insert_post`?
 * If you could share the code with us where you shared the logs, it would help 
   us replicate the issue on our side.
 *  Thread Starter [duttoluca](https://wordpress.org/support/users/duttoluca/)
 * (@duttoluca)
 * [9 months, 1 week ago](https://wordpress.org/support/topic/problem-with-post-generated-via-wp_insert_post-in-multisite/#post-18556138)
 * Yep, we use switch_to_blog before doing the inserts…
 * I’ll share the code with you ASAP, thank you

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Problem with posts generated via wp_insert_post in multisite’ is closed
to new replies.

 * ![](https://ps.w.org/wptelegram/assets/icon-256x256.png?rev=2500018)
 * [WP Telegram (Auto Post and Notifications)](https://wordpress.org/plugins/wptelegram/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wptelegram/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wptelegram/)
 * [Active Topics](https://wordpress.org/support/plugin/wptelegram/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wptelegram/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wptelegram/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [duttoluca](https://wordpress.org/support/users/duttoluca/)
 * Last activity: [9 months, 1 week ago](https://wordpress.org/support/topic/problem-with-post-generated-via-wp_insert_post-in-multisite/#post-18556138)
 * Status: resolved