gpt4 book ai didi

php - 尝试在 WordPress 中使用 DFP 广告管理系统定位 - 需要有关问题的建议 -

转载 作者:行者123 更新时间:2023-11-28 09:13:00 26 4
gpt4 key购买 nike

好的,这是我的情况:我在 DFP 广告管理系统中定义了以下自定义定位条件:

  • 键:smag-lps,值是 WordPress 中匹配的静态页面名称定位广告的目标网页
  • 键:postid,值 - 用户是允许输入帖子 ID 以将广告定位到帖子。

目标是转换针对创建广告时选择的页面名称或帖子 ID 的 DFP 广告。在我的 WordPress 主题 header.php 中我尝试过:

<script type='text/javascript'>
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
(function() {
var gads = document.createElement('script');
gads.async = true;
gads.type = 'text/javascript';
var useSSL = 'https:' == document.location.protocol;
gads.src = (useSSL ? 'https:' : 'http:') +
'//www.googletagservices.com/tag/js/gpt.js';
var node = document.getElementsByTagName('script')[0];
node.parentNode.insertBefore(gads, node);
})();
</script>
<script type="text/javascript">
googletag.cmd.push(function() {
googletag.pubads().set("adsense_background_color", "FFFFFF");
});
</script>
<script type='text/javascript'>
googletag.cmd.push(function() {
googletag.defineSlot('/2152723/SM-Leaderboard1', [728, 90], 'div-gpt-ad-1366056066154-0').addService(googletag.pubads());
.addService(googletag.pubads())
.setTargeting("smag-lps", "<?php echo get_current_page(); ?>")
.setTargeting("postid", "<?php echo get_the_ID(); ?>");
googletag.defineSlot('/2152723/SM-Leaderboard2', [728, 90], 'div-gpt-ad-1366056066154-1').addService(googletag.pubads());
.addService(googletag.pubads())
.setTargeting("smag-lps", "<?php echo get_current_page(); ?>")
.setTargeting("postid", "<?php echo get_the_ID(); ?>");
googletag.pubads().enableSingleRequest();
googletag.enableServices();
};
</script>

当我尝试使用 php echo 检索当前页面或 ID 时,我的网站正在崩溃。对我做错了什么有什么建议吗?

-M

最佳答案

你可以试试这个(你在脚本标签中,也许php代码与google代码出错)将引号添加到回显字符串中。

.setTargeting("smag-lps", <?php echo '"'.get_current_page().'"'; ?>)
.setTargeting("postid", <?php echo '"'.get_the_ID().'"'; ?>);

关于php - 尝试在 WordPress 中使用 DFP 广告管理系统定位 - 需要有关问题的建议 -,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16062147/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com