WordPress.org

Ready to get started?Download WordPress

Forums

do_shortcode inside switch_to_blog() (4 posts)

  1. kewalter
    Member
    Posted 3 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
    Moderator
    Posted 3 years ago #

    Is the plugin active on the other sites?

  3. kewalter
    Member
    Posted 3 years ago #

    Yeah.

  4. elfin
    Moderator
    Posted 3 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