Global pages

I'm looking for a way to have global pages on a multisite network. I want to publish one and same "Conditions"-page on each site.

Right now I'm actually creating pages each time a new subsite is created by hooking to wpmu_new_blog and using wp_insert_post(). It feels like a stupid solution, since if we want to change something in the "Conditions"-page we would need to edit each page on all sites.

Is there a way to call a global page from a subsite, WITHOUT leaving the subsite?

By the way, I read the the switch_blog() function is not good to use on front end. Is it really so?

  • DavidM
    • DEV MAN’s Mascot

    Hi danoman,

    Just to mention, are you aware of New Blog Template? With it, you can have that page automatically created with new blogs, among many other things.

    Similar to the method you've mentioned, it wouldn't let you update sites after they've been created, but it'd likely make things a bit easier.

    That said, you could always access the database directly, and I can't recall for sure but thought you might be able to use WP_Query to work with the data. Have you tried that?

    I haven't heard anything about not using switch_to_blog() on the main site, but that method is resource intensive and should be used with caution.


  • danoman
    • Flash Drive

    By the way I solved it this way:

    1. Create page, as above, when new site is generated and add shortcode [FooBar]
    2. Hook FoobarFunc to FooBar-shortcode.
    3. In FoobarFunc check if empty(get_option('baz')) then get_blog_option(1, 'baz').
    4. In FoobarFunc echo the content of option 'baz'.

    Don't know if it's a good solution, but it should give the customer quite good control of the content, and the possibility to use global content as well as override the global content with local stuff.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.