• Hello! Thank you so much for taking the time to read my post. Any help you’re able to offer would be greatly appreciated 🙂
    I need to have a different header appear in firefox than in all other browsers for my site.

    I currently have this code in my header:

    <head>
    	<script src="https://use.fontawesome.com/d450b61818.js"></script>
    	<meta charset="<?php bloginfo( 'charset' ); ?>">
    	<meta name="viewport" content="width=device-width, initial-scale=1">
    	<link rel="profile" href="http://gmpg.org/xfn/11">
    	<?php if ( is_singular() && pings_open( get_queried_object() ) ) : ?>
    	<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
    	<?php endif; ?>
    	<?php wp_head(); ?>
    	<?php echo do_shortcode( "[hmenu id=2]" ); ?>
    	<div class="top-bar">
    	<div class="top-countdown">
    	<a href="http://calvarytucson.com/teaching-archives/live/">
    	<button class="top-countdown-button"><div class="top-countdown-button-inner"><span class="firefox-live"><?php echo do_shortcode( '[countdown]' ); ?></span></div></button>
    	</a>
    	</div>
    	<div class="top-icons">
    	<a href="https://twitter.com/calvarytucson" target="_blank">
    	<button class="top-icons-button"><div class="top-icons-button-inner"><img src="https://calvarytucson.com/wp-content/uploads/2017/07/social-003_twitter-2.png" alt="Twitter"></div></button>
    	</a>
    	</div>
    	<div class="top-icons">
    	<a href="https://www.facebook.com/calvarychapeltucson" target="_blank">
    	<button class="top-icons-button"><div class="top-icons-button-inner"><img src="https://calvarytucson.com/wp-content/uploads/2017/07/social-006_facebook-2.png" alt="Facebook"></div></button>
    	</a>
    	</div>
    	<div class="top-icons">
    	<a href="https://www.instagram.com/calvarytucson/?hl=en" target="_blank">
    	<button class="top-icons-button"><div class="top-icons-button-inner"><img src="https://calvarytucson.com/wp-content/uploads/2017/07/social-038_instagram-2.png" alt="Instagram"></div></button>
    	</a>
    	</div>
    	</div>
    </head>

    and it seems line the code: <?php echo do_shortcode( '[countdown"]' ); ?> found on line 14 is causing the body of our site to be blank in firefox, and I know that it’s not the plugin itself causing the problem, as I’ve tried multiple plugins in that area and it all causes the same problem.

    I haven’t been able to find a work around that allows me to insert that shortcode without the php, or in a way that doesn’t break the site in firefox.

    So, I’m settling for having 2 different header files; one that pulls up in firefox, and one that pulls up for every other browser.

    This is the code that I’ve come up with so far, but I am pretty new to the code side of wordpress:

    if(strlen(strstr($agent,"Firefox")) > 0 ){      
        $browser = 'firefox';
    }
    if($browser=='firefox'){
        get_header( 'one' );
    }
    else{
        get_header();
    }

    and I have a file titled “header-one.php” where my header.php file is located with all the same code, but with text instead of the shortcode php.

    Is that correct? and is there a way to add that to my functions.php file to make that work, or do I need to go into all the places where my site calls for the header and replace it with that bit of code?

    Thank you again, very much!
    Chris Furrow

Viewing 3 replies - 1 through 3 (of 3 total)
  • The code looks right, but I’m afraid to say that you will need to add that to all of the template pages on your site that call get_header().

    There is another option though. You can do the check in your header.php file and do something like this…

    <?php
        if( false !== strpos( $_SERVER ['HTTP_USER_AGENT'], 'Firefox' ) ) {
            echo do_shortcode( '[countdown"]' );
        }
    >

    But… I’d also recommend checking to see what the actual error is so you can get mre insight into what is really going wrong. To do that, edit yor wp-config.php file and change

    define('WP_DEBUG', false);

    to

    define('WP_DEBUG', true);

    That will let you see any error messages that are being produced. Just remember to change it back when you’re done!

    Thread Starter Calvary Tucson

    (@cfurrow)

    oh, that’s a good idea, using the conditional logic to add the shortcode instead. I’ll try that and see if it works 🙂

    I also tried the debugging and found one error, which I fixed, but it didn’t seem to help.

    Thank you so much for the suggestions!! They are very helpful.

    Thread Starter Calvary Tucson

    (@cfurrow)

    It did work!! Thank you so much 🙂

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Problem in Firefox’ is closed to new replies.