do_shortcode inside switch_to_blog() (4 posts)

  1. kewalter
    Posted 5 years ago #

    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?

  2. elfin

    Posted 5 years ago #

    Is the plugin active on the other sites?

  3. kewalter
    Posted 5 years ago #


  4. elfin

    Posted 5 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic