WordPress.org

Forums

[resolved] Firefox uses header.php twice?! (4 posts)

  1. mindspins
    Member
    Posted 2 years ago #

    I use the following code in my header.php to keep track of the posts visited by users, but somehow Firefox stores two ID's on one page visit. The second ID is from the next page published. The last post published is the only page that gets me one ID, since there is no next post.
    Do you know what could be wrong?! I really appreciate all the help I can get, cause it keeps me puzzled for days now.

    <?php
    global $wp_query;
    $post_id = $wp_query->post->ID;
    $cookietime = time()+3600*24*365;
    $lt = '|';
    if (isset($_COOKIE['tst'])) {
    	$viewedstring = $_COOKIE['tst'];
    	$viewedstring .= $post_id.$lt;
    	setcookie('tst', $viewedstring, $cookietime, '/', '.domain.com');
    }else{
    	$viewedstring = $post_id.$lt;
    	setcookie('tst', $viewedstring, $cookietime, '/', '.domain.com');
    }
    ?>
  2. mindspins
    Member
    Posted 2 years ago #

    I guess it's a bug?! No WordPress wizards to help me out here?!

  3. mothra
    Member
    Posted 2 years ago #

    I've just spent a while hunting this down, it's related to Firefox's prefetching combined with wordpress's use of the rel=”next” meta tag.

    To remove these meta tags from your WordPress site, add the following to your theme’s functions.php file:

    For WordPress versions 3.0 and above:
    //remove auto loading rel=next post link in header
    remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');

    For older WordPress versions:
    //remove auto loading rel=next post link in header
    remove_action('wp_head', 'adjacent_posts_rel_link');

    See http://www.ebrueggeman.com/blog/wordpress-relnext-and-firefox-prefetching/

  4. mindspins
    Member
    Posted 2 years ago #

    Mothra,

    I honestly gave up already! You ROCK!

    Thanks again!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.