繁体   English   中英

在自定义主题的header.php文件中手动插入WordPress插件

[英]Manually insert a WordPress plugin inside custom theme's header.php file

好的,所以我有一个问题正在尝试解决,涉及WordPress插件。 我找到了一个我喜欢的画廊插件-几乎满足了我的所有要求-但问题是将短代码放置在内容编辑器中会导致将其放置在我拥有的横幅图像下方(此横幅图像存储在我的自定义主题的header.php文件,并且由于我正在处理的网站的布局而不得不转到该文件)。

我想做的是在此横幅图像之前在header.php中调用插件...但是我在弄清楚实现该目标所需要做的工作时遇到了麻烦。 当我在header.php文件中手动调用插件时,我了解到有可能需要删除register_activation_hook或activate_pluginname操作的信息。我是否需要以某种方式合并这些文件或在header.php文件中创建类似的功能?

这是我在header.php文件中所要达到的目的(我只想为主页加载此图库插件,因此要检查页面ID是否为主页ID):

  <div id="Container_Body" class="clearfix">
    <div id="topbox">
      <?php 
          $id = get_the_ID();
          $hpid = get_option('page_on_front');
          if($id == $hpid)
          {
            code to display plugin
          }
      ?>
      <div class="GalleryPlugin">
         <?php code to display gallery plugin ?>
      </div>
      <div class="giantBanner" style="background: rgb(0, 141, 175);">
        <img title="Main-Header-Banner" src="<?php bloginfo('template_directory'); ?>/images/Market-Crowd.jpg" alt="Market Crowd">
      </div>
    </div>

检查一下

  <?php 

   if(is_home() || is_front_page()) // this will check for homepage its a wp check
   {
        // echo the plugin shortcode here like
       echo do_shortcode('[gallery]');  // this will be any shortcode
   }
   ?>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM