• Resolved Shmoo

    (@macpresss)


    Hello,

    Can you create a function that will only get loaded on X blog_ID in the network?

    I mean. I have my WordPress MultiSite setup. Blog_ID #1 will act as front-page for all the sub-sites in the network, like some sort of hub to promote all sub sites. It will have it’s own unique theme and will probably never get touched after.

    All sub sites in the network will have another theme but what I don’t want is ending up with each site in the network getting another theme or a child of X theme. That’s so much ugliness for just 4 or 5 functions.
    What I really want is to load an external functions.php file into that theme for X blog ID.

    This would be the set-up:

    /my-first-theme/
    /my-second-theme/functions.php
    /my-second-theme/includes/functions-blog_2.php
    /my-second-theme/includes/functions-blog_3.php
    /my-second-theme/includes/functions-blog_4.php

    I will create those functions files myself manually, only when a sub-site really needs it.

    I have tried with switch_to_blog(2) and include …. file – but that didn’t work very well inside the functions.php file.

    Anyone know how to get this done?
    Thanks.

Viewing 1 replies (of 1 total)
  • Thread Starter Shmoo

    (@macpresss)

    This worked for me..

    global $blog_id;
    
    if ( $blog_id == 2 ) {
    
    	require get_template_directory() . '/includes/functions-blog_2.php';
    
    }
    if ( $blog_id == 3 ) {
    
    	require get_template_directory() . '/includes/functions-blog_3.php';
    
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Specific function-files for each blog ID?’ is closed to new replies.