【问题标题】:Removing google adsense breaks website - Wordpress custom_functions.php删除 google adsense 会破坏网站 - Wordpress custom_functions.php
【发布时间】:2010-10-31 05:43:30
【问题描述】:

我不久前在 wordpress custom_function.php 文件中添加了以下代码以显示 google adsense。现在我想删除代码,但是当我注释掉以下代码时我的网站中断了。我不明白为什么。请提供您对此的意见。

function sidebar_ads() {
?>
<script type="text/javascript"><!--
google_ad_client = "pub-xxxxxx";
/* 160x600, created 9/23/10 for SideBar */
google_ad_slot = "xxxxx";
google_ad_width = 160;
google_ad_height = 600;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<?php }
add_action('thesis_hook_before_sidebars', 'sidebar_ads');

【问题讨论】:

  • 你能用你遇到的错误更新你的问题吗?
  • 我在 wordpress 文件编辑器中编辑这个。在我保存删除上述代码的文件后,站点就中断了。我的意思是我的网址中没有任何内容。我必须 FTP 并替换这个文件才能让它再次工作。

标签: php wordpress adsense


【解决方案1】:

您可以像这样简单地将带有 add_action 的行注释掉

// add_action('thesis_hook_before_sidebars', 'sidebar_ads');

这应该会停止调用该函数,并且您应该没有广告:D

或者,注释掉整个事情:

/*
function sidebar_ads() {
?>
<script type="text/javascript"><!--
google_ad_client = "pub-xxxxxx";
// 160x600, created 9/23/10 for SideBar 
google_ad_slot = "xxxxx";
google_ad_width = 160;
google_ad_height = 600;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<?php  }
add_action('thesis_hook_before_sidebars', 'sidebar_ads'); */

我假设您尝试过嵌套多行 cmets。这是不允许的(在我所知道的每一种语言中)。 请注意,我将注释更改为“160x600,为 SideBar 创建 9/32/10”以使用双斜杠,因此您可以将整个内容包含在 /* */

【讨论】:

  • 是的,这行得通。但是为什么删除上面的代码会搞砸一切仍然是个谜。我想要一个干净的代码:)
  • 我已经用注释掉整个代码块的解决方案更新了我的答案。
猜你喜欢
  • 2011-03-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-12-28
  • 1970-01-01
相关资源
最近更新 更多