• Hi, I am about to start working on this multisite website. We have one of the sites will have 4,000 posts (profile page). Am I able to use a Short code to call a profile (post) on a sister website?

    For example, Page one calls a profile using a short code from page two.

    For example: [john-smith]

    What could I use to do that?

    Thank you,

    • This topic was modified 3 years, 8 months ago by CreativeWP.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    PHP (and hence shortcodes) can fetch any post from any subsite, regardless of the current site. The key is to use switch_to_blog() before making the query. Remember to call restore_current_blog() afterwards.

    You shouldn’t want a unique shortcode for every profile like [john-smith]. Instead pass the desired user as an argument, as in [profile user=”john-smith”]. Yes, it’s more typing, but much less code overhead, keeping your site more performative. You must avoid having thousands of unique shortcodes.

    With a few lines of code you could write a shortcode that switches you to another blog. When you are done, you have another shortcode to restore to the current blog. I guess if doing this, you could use any shortcode from a sister site to create output.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Using Short codes of sister Multisite’ is closed to new replies.