donglu8344812
2012-01-21 14:48 阅读 55
已采纳

Wordpress广告:每个页面刷新计为多个插件上的3次广告展示(更新:随机#取决于谁查看和浏览器))

I have tried multiple plug-ins for ads and for each page refresh they all count it as 3 impressions.

Any idea why this is happening or how to fix it?

Currently using the Ad Engine plugin, and already tried Simple Ads Manager. Using an Image.

Example Code:

                    <!doctype html>
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!-- Consider adding an manifest.appcache: h5bp.com/d/Offline -->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
  <meta charset="utf-8">

  <!-- Use the .htaccess and remove these lines to avoid edge case issues.
       More info: h5bp.com/b/378 -->
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

  <!--Wordpress Template-->
  <title><?php bloginfo('name'); ?> <?php wp_title(); ?></title>  
  <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />  

  <?php wp_head(); ?>

  <meta name="description" content="Saint Petersburg SociaBulls">
  <meta name="author" content="Austin Piazza">

  <!-- Mobile viewport optimized: j.mp/bplateviewport -->
  <meta name="viewport" content="width=device-width,initial-scale=1">

  <!-- Place favicon.ico and apple-touch-icon.png in the root directory: mathiasbynens.be/notes/touch-icons -->

  <link rel="stylesheet" type="text/css" href="<?php bloginfo('wpurl'); ?>/wp-content/themes/sociabulls/js/jcar/skins/tango/skin.css" />

  <!-- CSS: implied media=all -->
  <!-- CSS concatenated and minified via ant build script-->
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen,projection" />  
  <!-- end CSS-->

  <!-- More ideas for your <head> here: h5bp.com/d/head-Tips -->

  <!-- All JavaScript at the bottom, except for Modernizr / Respond.
       Modernizr enables HTML5 elements & feature detects; Respond is a polyfill for min/max-width CSS3 Media Queries
       For optimal performance, use a custom Modernizr build: www.modernizr.com/download/ -->
  <script src="<?php bloginfo('wpurl'); ?>/wp-content/themes/sociabulls/js/libs/modernizr-2.0.6.min.js"></script>


  <!-- end scripts-->

  <script type="text/javascript">
jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        // Configuration goes here
    });
});
</script>

  <link href='http://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'>
</head>

<body <?php body_class($class); ?>>

  <div class="wide" id="container">
    <header id="sticky" class="wide">
        <div class="center">
        <a href="#"><h1 id="logo" class="notext">St. Pete Sociabulls</h1></a>
        <ul id="nav">
            <?php wp_list_pages('title_li='); ?>
        </ul>
        </div>
    </header>

<div id="page">
<div id="top"><div id="city"></div></div>
<div id="main" role="main" class="wide">
    <div id="full">
        <div class="center">
            <div id="moveup">

                <div id="main-event">
                     <h2><?php the_title('');?></h2>
                     <?php if (have_posts()) : while (have_posts()) : the_post();?>
                     <div class="whole-post">

                         <div class="post-date">
                            <?php the_date( 'M d' ); ?>
                         </div>
                         <div class="entry">
                             <div class="entrytext">
                                  <?php the_content(); ?>
                             </div>
                         </div>
                     </div>
                   <?php endwhile; endif; ?>
                </div>

                <aside>

                    <?php if ( !function_exists('dynamic_sidebar')  
        || !dynamic_sidebar( 'rightsidebar' ) ) : ?> 
<?php endif; ?> 

<div id="ad-box">
                    <?php if ( !function_exists('dynamic_sidebar')  
        || !dynamic_sidebar( 'Ads' ) ) : ?> 
<?php endif; ?> 
</div>

                </aside>

             </div>
            </div>
        </div>
    </div>
  </div> 


<footer class="wide">
         <div id="seawall">
            <div class="center">
                <div id="sponsors">
                    <?php if ( !function_exists('dynamic_sidebar')  
        || !dynamic_sidebar( 'extra' ) ) : ?>
 <p>This is the deafult sidebar, add some widgets to change it.</p>  
<?php endif; ?> 

                </div>
                <div id="social-page">
                    <div class="fb-like-box" data-href="http://www.facebook.com/swingstampabay" data-width="350" data-height="170" data-show-faces="true" data-stream="false" data-header="false"></div>
                </div>
            </div>
         </div>
    </footer>
  </div> <!--! end of #container -->


  <!-- JavaScript at the bottom for fast page loading -->

  <!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if offline -->
  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
  <script>window.jQuery || document.write('<script src="js/libs/jquery-1.6.2.min.js"><\/script>')</script>
  <script type="text/javascript" src="<?php bloginfo('wpurl'); ?>/wp-content/themes/sociabulls/js/jcar/lib/jquery.jcarousel.js"></script>

  <!-- scripts concatenated and minified via ant build script-->
  <script defer src="js/plugins.js"></script>
  <script defer src="js/script.js"></script>

  <div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=270668269621466";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=265187160174054";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>


  <!-- Change UA-XXXXX-X to be your site's ID -->
  <script>
    window._gaq = [['_setAccount','UAXXXXXXXX1'],['_trackPageview'],['_trackPageLoadTime']];
    Modernizr.load({
      load: ('https:' == location.protocol ? '//ssl' : '//www') + '.google-analytics.com/ga.js'
    });
  </script>


  <!-- Prompt IE 6 users to install Chrome Frame. Remove this if you want to support IE 6.
       chromium.org/developers/how-tos/chrome-frame-getting-started -->
  <!--[if lt IE 7 ]>
    <script src="//ajax.googleapis.com/ajax/libs/chrome-frame/1.0.3/CFInstall.min.js"></script>
    <script>window.attachEvent('onload',function(){CFInstall.check({mode:'overlay'})})</script>
  <![endif]-->

  <?php wp_footer(); ?>  

</body>
</html>

Plugin Code: https://gist.github.com/1654868

Update: Added all my code together

Thanks!!

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • 已采纳
    douxuanjie2692 douxuanjie2692 2012-01-22 04:28

    NEVER NAME THINGS ANYTHING CLOSE TO NORMAL!!!!

    I can't believe this entire problem was from naming my widget area 'ads'...

    点赞 评论 复制链接分享
  • dqdjfb2325 dqdjfb2325 2012-01-21 23:07

    One thing to check:

    Does it happens with different themes? Case not, In what API hook is the plugin's counter hooked?

    Chances are that your template/theme is following a non standard pattern and causing a given hooker to be activated more than once per page load.

    In case the problem is being triggered by your theme, we are on a tricky situation to debug. Plugin API Hooks are a bit numerous and can be fired in many parts of the theme, take a look at this reference:

    http://codex.wordpress.org/Plugin_API/Action_Reference

    Some approaches:

    If the plugin source code is not too large, you can take a look at it and look for use of hooks, than you can figure out where the repetition of events are happening.

    Compare your theme with the functional theme and see if you're doing some anti pattern. I would start for the header part, sidebar, and footer. The number of repetitions (3) can be a good tip too.

    Are you repeating a given piece of code 3 times in your theme? Does your post loop runs exactly 3 times?

    Theoretically the problem code could be anywhere, but give some attention to compare your header with the functional theme's header, it's one of the most critical parts of a theme.

    点赞 评论 复制链接分享