The MU forums have moved to WordPress.org

Page tries to grab wrong header Image (10 posts)

  1. truck808
    Member
    Posted 14 years ago #

    On a sub blog a page does not grab the correct header image. Instead it grabs an image from the home page of the main web site. This happens every once in a while.

    Wrong Header

    Correct Header

    Home Page Header

    Thanks in advance.

    Robert

  2. truck808
    Member
    Posted 14 years ago #

    If anyone else has experienced this I could use some advice.

    Thanks!

    Robert

  3. andrea_r
    Moderator
    Posted 14 years ago #

    It's probably that the theme is not MU-aware.

  4. truck808
    Member
    Posted 13 years ago #

    Andrea - thank you for your response.

    Can you point me in the right direction on how to make the theme MU-aware?

    I really appreciate your help.

    Robert

  5. andrea_r
    Moderator
    Posted 13 years ago #

    I mean in the sense of, if the theme author has written custom coding that searches & uses the default single WP uploads folder, that is exactly why the headers break in MU.

    If the theme uses the built-in custom header option it will work in MU.

    (while I have seen the theme in question, I haven't used it. 98% of the themes I've tried work just fine & dandy in MU. It's the custom coding that falls down.)

    Also, just looking at the one that is *not* working right.... the header is larger than the header div that contains it. If the theme has options to make that box bigger, then you forgot that part.

    It;s an easy check too. On this blog: http://www2.nya.org/

    Look at the header div. it;s 314px high.
    On the one that is "wrong", the div is 15ipx high, smaller than the picture you;re trying to contain.

    Now that I think of it, it's more a general themeing issue and less of an MU one.

  6. benknight
    Member
    Posted 13 years ago #

    Hello, I'm a developer working with Robert. I thought I would shed some light on the issue and offer some specifics and see where we might get.

    This theme is actually completely custom coded so it's not an issue of the theme breaking when being implemented on a MU.

    So, the details. This theme loads a different CSS header depending on whether the home page is being viewed or a non-home page which I'll call an "inner" page. The PHP logic is the following:

    switch_to_blog(1);
    
    if(is_front_page()) :
    
    [markup for home page header]
    
    else :
    
    [markup for inner page]
    
    endif;
    
    restore_current_blog();

    So basically there's a 314px high header that's only meant to be loaded when we're viewing the main blog (blog id 1). In all other cases, whether it's the home page of a sub blog or it's an inner page of the main blog, the 151px high header should be loaded.

    In almost all cases this works exactly as described above. However as Robert described we get this "freak" cases where for whatever reason is_front_page() is returning true on pages that aren't the main blog's home page. The only way we've been able to fix this is by deleting the page from the WP admin, and then recreating the page with the exact same title, content, page hierarchy, etc.

    So in my mind since this is completely unpredictable behavior I don't see how we could arrive at any conclusion except that this must be a WPMU bug. Maybe I'm wrong though - in fact I hope I am for the client's sake!

    Ben

  7. andrea_r
    Moderator
    Posted 13 years ago #

    The switch_to_blog is the issue. Every time you run that it literally is going to the main blog and getting those conditions.

    If you only want that header to be shown on the main blog, there's no need to check for it on sub-blogs, as you alreayd know you're not on the main blog.

    try if(is_main_blog() && is_front_page()) : take out the switch_to_blog and restore_current_blog.

  8. benknight
    Member
    Posted 13 years ago #

    Andrea, thanks for offering a solution. I see your point and agree that you logic is technically more elegant. Still though there's no reason why this should break like it is and there still seems to be no clear explanation as to why it's happening. is_front_page() should return false for in any case when the current blog's home page is not being viewed - plain and simple. I would wager a guess that the is_front_page() function is occasionally returning erroneous results when the page in question is not within the active blog.

    I'll try implementing that logic, however it'll be hard to know if that actually solves the issue for good. As far as I know there's no function called "is_main_blog()" - at least it's not documented here: http://codex.wordpress.org/WPMU_Functions. I was able to use the global $blog_id variable however to do this. It appears to work, so thank you!

    Ben

  9. andrea_r
    Moderator
    Posted 13 years ago #

    is_front_page() should return false for in any case when the current blog's home page is not being viewed - plain and simple.

    But you wrapped it in switch_to_blog(1), which mean that the logic that then follows only applies to blog1, the main blog, regardless of what blog you're on.

  10. truck808
    Member
    Posted 13 years ago #

    It's working now - Thanks!

About this Topic

  • Started 14 years ago by truck808
  • Latest reply from truck808