WordPress.org

Forums

Conditional tags for multisite? (12 posts)

  1. bwinn
    Member
    Posted 4 years ago #

    Just wondering if this is possible...

    I have 1 theme I want to use across all subsites in my network. However I want certain items to be placed within the sidebar or header that the site owners cannot modify (thats why widgets wouldnt work Im guessing).

    Is there a way to say: if its site1.mydomain.com show banner 1. If it's site2.mydomain.com show banner 2? etc?

    Thanks!

  2. However I want certain items to be placed within the sidebar or header that the site owners cannot modify (thats why widgets wouldnt work Im guessing).

    I just explained that in this thread:
    http://wordpress.org/support/topic/problems-with-widgets-when-using-multisites

  3. bwinn
    Member
    Posted 4 years ago #

    Andrea you will go down as the most helpful person in the WordPress community of all time. Mark my words & thanks so much too!

  4. bwinn
    Member
    Posted 4 years ago #

    I actually just read that thread and its not what I am looking for. I am looking for a way to display certain banner ads on sites within my network. I want to hardcode the banner code, but I only want to use one theme.

    So I will have different banner ads for different people in my network. For example: johnsmith.com will have a coke banner ad, but jillsmith.com will have a pepsi ad. Does that make sense?

    I would go into sidebar.php and hardcode this in with a conditional tag but I dont think you can do that in this case, or can you?

    Can you say if johnsmith.com ><img src="pepsi.jpg">
    If jillsmith.com ><img src=coke.jpg"> etc???

    Does that make sense?

  5. Yes, you can. It's not fun on larger sites though.

    global $blog_id;
    if( $blog_id == '2' ) {
    //do some comment stuff for blog 2
    }

    and on and on....

  6. bwinn
    Member
    Posted 4 years ago #

    Is there a plugin that allows the super admin to create invisible widgets that other users and even other site admins cant touch?

    That would be very very helpful. But thanks for your response. I appreciate it.

  7. David Sader
    Member
    Posted 4 years ago #

    Is there a plugin that allows the super admin to create invisible widgets

    Plugin to create widgets? No. Get coding. Easy peasy lemon squeezy.

    Add the call/hook to the widgety looking function in each theme, but keep the function in "mu-plugins":

    Add to each theme in your arsenal of themes

    <?php if(function_exists('my_super_admin_widget')) {
    my_super_admin_widget();
    }
    ?>

    But keep the following in "mu-plugins"

    <?php
    function my_super_admin_widget() {
    global $blog_id;
    if( $blog_id == '2' ) {
    //do some widgety looking stuff for blog 2
    }
    //and so on
    }
    ?>
  8. bwinn
    Member
    Posted 4 years ago #

    So all I am doing is adding that code to sidebar.php file and creating a new php file and dumping it into mu-plugins?

    I tried this and it's not working.

    Can you show what the code would look like if I wanted to insert an image instead of commented out text?

    Thanks!

  9. David Sader
    Member
    Posted 4 years ago #

    //do some widgety looking stuff for blog 2
    becomes
    echo '<img src="kjaskdjhakjskd.jpg" />';

  10. bwinn
    Member
    Posted 4 years ago #

    high five!

  11. bwinn
    Member
    Posted 4 years ago #

    Can I echo php??

  12. bwinn
    Member
    Posted 4 years ago #

    Would love to include something like this:

    <?php if (function_exists('easing_slider')){ easing_slider(); }; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic