【问题标题】:Adsense ads display issueAdsense 广告显示问题
【发布时间】:2013-08-11 13:38:21
【问题描述】:

广告未出现在与 2 个类别相关的特定 2 个页面中,这些类别包含最新文章和阅读次数最多的文章,其他类别使用管理面板添加,并且仅在撰写文章时指定类别时才链接文章(或来自数据库) php代码中可能是什么东西会使广告仅出现在这两个类别中。请您列出导致php和javascript等冲突的可能原因。或者它可能是一些需要加载的php或apache扩展楼主..

//更新// 广告显示在本地主机上,但未显示在远程服务器上// 但请注意,只有这 2 个动态类别没有展示广告;像这样加载php:
热门文章

// Popular articles link
    $popular_li_class = '';
    if ($show_popular)
    {
        $popular_li_class = ' class="selectedcat" ';
    }

    if (_SEOMOD)
    {
        $output = '<li '. $popular_li_class .'><a href="'. _URL .'/articles/popular-01.'. _FEXT .'">'.$lang['articles_mostread'].'</a></li>'. $output;
    }
    else
    {
        $output = '<li '. $popular_li_class .'><a href="'. _URL .'/article.php?show=popular">'.$lang['articles_mostread'].'</a></li>'. $output;
    }

和最新文章类别:

//  wrapper
    $output = '<li><a href="'. _URL .'/article.'. _FEXT .'">'.$lang['articles_latest'].'</a></li>'. $output;

    //  wrapper
    if ($ul_wrapper)
    {
        $output = "<ul id='ul_categories'>\n$output\n</ul>";
    }   
    return $output;
}

任何帮助将不胜感激。 谢谢。

【问题讨论】:

  • 你的代码在哪里,你试过什么?有截图吗?我们需要更多信息!
  • 您可以将其粘贴到 pastebin.com 上,然后添加一个链接...这样会更容易。
  • 哪个部分不工作?
  • 您的源代码根本不包含 Adsense 代码。它是否包含在另一个文件中?您的 &lt;script&gt;&lt;/script&gt; 包含 javascript 的标签在哪里?有关显示 adsense 的简单方法,请参阅我的更新答案。
  • 我明白了!它在本地主机上工作!那么什么是 php 或 apache 中的扩展可以做到这一点呢?告诉我所有可能在 localhost 上禁用的扩展,看看它们是否会消失。

标签: php javascript apache adsense


【解决方案1】:

Adsense 代码只是包含在 &lt;script&gt;&lt;/script&gt; 标记中的 JavaScript 代码。如果您的 php 代码生成包含此代码的 html,则它会正确加载到客户端的浏览器上,并显示广告。检查您的 php 代码是否包含任何阻止 javascript 代码输出的错误。您可以查看生成的源代码。

显示 adsense 代码就像在 php 代码中编写以下代码一样简单:

include_once("adsense1.php");

其中 adsense1.php 包含:

<script type="text/javascript"><!--
google_ad_client = "ca-pub-";
google_ad_slot = "xxx";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">

或者,您甚至可以这样做:

<?php

print '<script type="text/javascript"><!--
    google_ad_client = "ca-pub-";
    google_ad_slot = "xxx";
    google_ad_width = 728;
    google_ad_height = 90;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>';
?>

【讨论】:

  • 在这种情况下,您的 php 代码可能包含错误。没有源代码很难评论。
  • 广告在 localhost 上加载,但在这 2 个页面上无法远程工作......那么 php 或 apache 中的扩展是什么?请更新你的答案我更新了问题..
猜你喜欢
  • 2014-10-14
  • 2016-07-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-12
  • 1970-01-01
  • 2021-12-26
  • 2016-09-25
相关资源
最近更新 更多