单页广告也显示在主页上

时间:2011-09-11 15:06:37

标签: php css wordpress content-management-system

我的域名www.spiceygames.com(此网站使用来自themeforest的创新科学2(cms)主题)的广告存在问题。看一下主页面,在滑块下面显示我的adsense广告。

这些广告实际上来自单个帖子,我会通过快速adsense插件添加它们,并且它们在单个帖子上工作正常。

问题出现在主页上,单个帖子广告也显示在主页面上,我不想在主页面上显示它们。我认为css / theme文件中存在一些错误。那么我该如何解决呢?

<?php
/**********************************************************************
* INNOVATION SCIENCE WORDPRESS THEME  
* (Ideal For Business And Personal Use: Portfolio or Blog)   
* 
* File name:   
*      single.php
* Brief:       
*      Theme single page code
* Author:      
*      DigitalCavalry
* Author URI:
*      http://themeforest.net/user/DigitalCavalry
* Contact:
*      digitalcavalry@gmail.com   
***********************************************************************/ 
get_header();        

$catlist = wp_get_post_categories($post->ID);
$catlist = wp_get_post_terms($post->ID, 'category');
$count_cat = count($catlist);

$extname = array();
if($count_cat > 0)
{       
   foreach($catlist as $cat)
   {
       $extname[$cat->name] = get_category_link($cat->term_id);
   } 
}   

if(!isset($_SESSION[('pv'.$post->ID)])) { $_SESSION[('pv'.$post->ID)] = false; } 
if(isset($_SESSION[('pv'.$post->ID)]) and $_SESSION[('pv'.$post->ID)] == false)
{   
    $post_visits = get_post_meta($post->ID, 'post_visits', true);
    if($post_visits == '') { $post_visits = 0; } else { $post_visits++; }
    update_post_meta($post->ID, 'post_visits', (int)$post_visits);
    $_SESSION[('pv'.$post->ID)] = true; 
}                                                 
?>

<!-- google_ad_section_start -->
<div id="content">            
    <?php 


        $post_common_opt = $GLOBALS['dc_postcommon_opt'];            
        $post_custom_content = (bool)$post_common_opt['post_custom_cbox'];
        $post_fullwidth = (bool)$post_common_opt['post_fullwidth_cbox'];

        if($post_custom_content and $post_fullwidth)
        {
            echo '<div class="page-width-full">';        
        } else
        {
            GetDCCPInterface()->getIGeneral()->includeSidebar($post_common_opt['page_sid'], $post_common_opt['page_sid_pos']);

            if(GetDCCPInterface()->getIGeneral()->getSidebarGlobalPos($post_common_opt['page_sid_pos']) == CMS_SIDEBAR_RIGHT)
            {
                echo '<div class="page-width-left">';                              
            } else
            {
                echo '<div class="page-width-right">';     
            }
        }      
        dcf_naviTree($post->ID, 0, '', $extname);         

        if($post_custom_content)
       {
            the_content();    
        } else
        {           
            GetDCCPInterface()->getIRenderer()->renderBlogPostFull();
        }

        if('open' == $post->comment_status)
        {
            echo '<a name="comments"></a>';
            comments_template();
        }
    ?>

注意 - 我将使用Quick adsense wordpress插件插入广告。

1 个答案:

答案 0 :(得分:0)

你在使用什么作为主页?页面/自定义模板/索引页面?您可以在adsense代码中添加条件块,以便将其显示在除主页之外的所有页面上,如下所示:

<?php if ( ! is_home() ) {?>
   <!--Ads1-->
<?php }?>