我已将其添加到标题中.php在WordPress中...
<?php // Block Google Adsense on these post ID's?>
<?php Global $ad_flg; $ad_flg=1; ?>
<?php $adsense_blck_post = array(7130, 7151); ?>
<?php if (in_array($post->ID,$adsense_blck_post,true)) $ad_flg=0; ?>
<?php // STOP Blocking Google Adsense on these post ID's?>
然后,为了阻止单个广告位,我围绕广告代码实现了此代码。
global $ad_flag;
if($ad_flag!=0) {
echo td_global_blocks::get_instance('td_block_ad_box')->render(array('spot_id' => 'post_style_12'));
}
但是,当我在此示例中添加它时,它不起作用。有人可以告诉我我做错了什么吗?
//add the top ad
global $ad_flag; if (td_util::is_ad_spot_enabled('content_top') and is_single() and $ad_flag!=0) {
$content = td_global_blocks::get_instance('td_block_ad_box')->render(array('spot_id' => 'content_top')) . $content;
}
您正在设置一个名为 $ad_flg
的变量并检查一个名为 $adsense_flag
的变量。 尝试在两个位置使用相同的名称。