A floating div for all subdomains

Hi, do you guys know a plugin or a good way for inserting a floating div into some of my sub sites in a wpms installation? Thank you!

  • Michael Bissett
    • Recruit

    Hey @diegpl, hope you're doing well this evening! :slight_smile:

    Could I ask you to elaborate as to what this floating div's supposed to be for, are you thinking of a menu here? Also, while your question title says you want this to show up on "all subdomains", you mention that you want this in "some of my subsites", which one should I have in mind here?

    I ask because if you're wanting this across all subdomains, then this could probably be achieved with a simple mu-plugin (though it would depend on several factors, like the subsite's theme, how complex this floating div is to be, etc).

    Please advise,
    Michael

  • Michael Bissett
    • Recruit

    Hey @diegpl! :slight_smile:

    Okay, so you're wanting a floating <div> element that only shows up on your template sites (that doesn't get copied over when a user creates a new site), something like an incentive to register for a new site, right?

    I wouldn't want to enable a plugin site by site for this, as the plugin would then be active on newly created sites as well (assuming that any active plugins on the template site are set to be active when a user creates a new site using that template).

    Something like this comes to mind, as a basic template that you could use for a mu-plugin:

    add_action( 'wp_head', 'example_div_load_code' );
    
    function example_div_load_code() {
    
    $blog_id = get_current_blog_id();
    
    $blog_list = array(1, 2, 3, 4);
    
    if ($blog_id = in_array($blog_id, $blog_list) ) {
    // enter your code to run here;
    }
    
    }

    You'd need to get the blog IDs, and enter them in the array for the $blog_list variable, so that way your code only runs on those sites. :slight_smile:

    Hope this helps!

    Kind Regards,
    Michael

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.