Support » Fixing WordPress » do_shortcode inside switch_to_blog()

  • I’m using WP multisite. I set up a contact form 7 form on my main site and I’m trying to include that form inside other sites via the theme.

    I used switch_to_blog() to switch to the site with the form and used do_shortcode(), but it doesn’t work. The form works fine in the theme of the main blog but once I put it inside switch_to_blog() it stops working. Are you not allowed to use shortcodes after switching blogs?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Is the plugin active on the other sites?


    Hmm, the odds are as it is a shortcode it is going to use the active plugin for that blog, and as such the form you created won’t get displayed.

    But you have to echo a shortcode, so why not store it in a variable, then switch to blog, and then echo.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘do_shortcode inside switch_to_blog()’ is closed to new replies.