如何在wordpress网站上的页面加载上添加pop横幅?

时间:2014-11-06 11:17:28

标签: php html wordpress widget

我有广告代码。

<div id='div-gpt-ad-1373299297661-0-oop'>
<script type='text/javascript'>
googletag.display('div-gpt-ad-1373299297661-0-oop');
</script>
</div>

我应该在哪里添加它以在页面加载时弹出。 我将此代码添加到<body>标记下的header.php文件中。 但它显示在header.it的顶部,应该在页面中间弹出。

的header.php

<body <?php body_class();?> itemscope="itemscope" itemtype="http://schema.org/WebPage">

<!-- 450x450 -->
<!-- Overylay Banner -->
<div id='div-gpt-ad-1373299297661-0-oop'>
<script type='text/javascript'>
googletag.display('div-gpt-ad-1373299297661-0-oop');
</script>
</div>


<?php 
if(of_get_option('full_or_boxed_layout')!= 'full_image_option'){
if(of_get_option('background_body_option')== 'big_image'){?>
<img alt="full screen background image" src="<?php echo of_get_option('background_large_image');?>" id="full-screen-background-image" />
<?php }}?>



<div id="content_nav">

        <div id="nav">
        <?php $top_menu = array('theme_location' => 'Top_Menu', 'container' => '', 'menu_class' => 'menu-top-menu-sf', 'menu_id' => '', 'fallback_cb' => false); wp_nav_menu($top_menu);?>
        <?php $main_menu = array('theme_location' => 'Main_Menu', 'container' => '', 'menu_class' => '', 'menu_id' => '', 'fallback_cb' => false, 'link_after'=>'<span class="border-menu"></span>'); wp_nav_menu($main_menu);?>
   </div>
    </div>    
<?php if(of_get_option('full_or_boxed_layout') == 'box_image_option'){ if(of_get_option('background_option') == 'background_image'){?>
<div class="full-background"><img  src="<?php echo of_get_option('background_large_image');?>" alt="" /></div>
<?php }}?>

<div id="sb-site" class="<?php if(of_get_option('full_or_boxed_layout') == 'full_image_option'){echo "body_wraper_full";}else{echo "body_wraper_box";}?>">                  


<div>

        </div>
<!-- Start header -->
<header class="header-wraper">

<div class="header_top_wrapper">
<?php $main_top = array('theme_location' => 'Top_Menu', 'container' => '', 'menu_class' => 'sf-top-menu', 'menu_id' => 'menu-top', 'fallback_cb' => false);?>
<div class="row <?php if($main_top == "" || !of_get_option('disable_top_menu')==0){echo "no-top";}?>">
<div class="six columns header-top-left-bar">

  <a class="open toggle-lef sb-toggle-left navbar-left" href="#nav">
                <div class="navicon-line"></div>
                <div class="navicon-line"></div>
                <div class="navicon-line"></div>
                </a>
<?php if(!of_get_option('disable_top_menu')==1){?>



  <div class="mainmenu"> 
<?php wp_nav_menu($main_top);?>
<div class="clearfix"></div>
</div>
<?php }?>

</div>

<div class="six columns header-top-right-bar">
<?php if(!of_get_option('disable_top_search')==1){?>
      <div id="search_block_top">
    <form id="searchbox" action="<?php echo home_url(); ?>" method="GET" role="search">
        <p>
            <input type="text" id="search_query_top" name="s" class="search_query ac_input" value="" placeholder="<?php _e('Search here', 'jelly_text_main'); ?>">
            <a class="button_search" href="javascript:document.getElementById('searchbox').submit();"></a>
    </p>
    </form>
    <span>Search</span>
    <div class="clearfix"></div>
</div>
<?php }?>
<?php if(!of_get_option('disable_top_header_date')==1){?>
<div class="clock">
<i class="fa fa-clock-o"></i>
<div id="Date">
<?php
/*setlocale(LC_TIME, "pt_BR");
$currDate = strftime("%e %B, %Y, %H:%M");
echo $currDate;*/
?>

<?php echo date('l j F Y');  //setlocale(LC_TIME, "de_DE"); echo strftime('%A %d %B %Y');?></div>
  <ul>
      <li id="hours"></li>
      <li class="point">:</li>
      <li id="min"></li>
      <li class="point">:</li>
      <li id="sec"></li>
  </ul>
</div>
<?php }?>

<div class="clearfix"></div>
</div>

</div>
</div>



 <div class="header_main_wrapper">
        <div class="row">



    <div class="<?php if (is_active_sidebar('banner-sidebar')) { echo'four columns header-top-left'; } else { echo'twelve columns logo-position';}?>">



      <!-- begin logo -->


                                <a href="<?php echo home_url(); ?>">
                                    <?php $logo = of_get_option('logo_uploader'); ?>
                                    <?php if (!empty($logo)): ?>   
                                        <img src="<?php echo $logo; ?>" alt="<?php bloginfo('description'); ?>"/>
                                    <?php else: ?>
                                        <img src="<?php echo get_template_directory_uri(); ?>/img/logo.png" alt="<?php bloginfo('description'); ?>"/>


                                   <?php endif; ?>
                                </a>

                            <!-- end logo -->




    </div>

    <?php if (is_active_sidebar('banner-sidebar')){ ?>


    <div class="eight columns header-top-right">  


  <?php dynamic_sidebar('banner-sidebar');?>



    </div>
    <?php }?>  


</div>

</div>


<!-- end header, logo, top ads -->


<!-- Start Main menu -->

那么我应该在哪里放置广告代码?

是否可以通过文本小部件添加叠加横幅?没有编辑header.php ??

1 个答案:

答案 0 :(得分:0)

要在页面加载时加载某些内容,您需要将其添加到<body>标记本身,如下所示:

<body onLoad="callJSFunction()">
.
.
.
</body>

看看this教程:D