douchi0471
2015-04-21 12:21
浏览 190
已采纳

我如何在wordpress主题目录之外使用header.php和footer.php

I have a theme installed in wordpress like this directory /wp-content/themes/mytheme so in the root I have custom code which is little complex and easy to integrate in wordpress theme so I want to finding an option where I can use header.php and footer.php in root directory like this way. /custom_code/custom.php

图片转代码服务由CSDN问答提供 功能建议

我在wordpress中安装了一个主题,就像这个目录 / wp-content / themes / mytheme 所以在root中我有自定义代码,它很复杂,很容易集成到wordpress主题中,所以我想找一个选项,我可以使用 header.php footer.php 在这样的根目录中。 /custom_code/custom.php

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • duanluan3651 2015-04-21 15:53
    已采纳

    After a lot of searching here is the solution.

    <?php require('../wp-blog-header.php'); ?>
    
    <?php get_header(); ?>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-
    
    transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo
    
    ('charset'); ?>" />
    <title><?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> » Blog Archive <?php } ?> <?php
    
    wp_title(); ?></title>
    
    <?php wp_head(); ?>
    </head>
    
    <body>
    It works!
    
    </body>
    </html>
    
    <?php get_footer(); ?>

    </div>
    
    已采纳该答案
    打赏 评论
  • doutang1884 2015-04-21 15:53

    Include header.php and footer.php like this: http://codex.wordpress.org/Integrating_Wordpress_with_Your_Website

    From the page:

    <?php 
    /* Short and sweet */
    define('WP_USE_THEMES', false);
    require('./wp-blog-header.php');
    ?>
    
    打赏 评论

相关推荐 更多相似问题