繁体   English   中英

我如何从wordpress主题目录中使用header.php和footer.php

[英]how I can use header.php and footer.php outside from wordpress theme directory

我在wordpress中安装了一个主题,例如/wp-content/themes/mytheme因此在根目录中,我具有自定义代码,该代码很少复杂,易于集成到wordpress主题中,因此我想找到一个可以使用header.php的选项header.phpfooter.php在根目录中是这样的。 /custom_code/custom.php

经过大量搜索后,这里是解决方案。

 <?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(); ?> 

像这样包含header.php和footer.php: http : //codex.wordpress.org/Integrating_Wordpress_with_Your_Website

从页面:

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

暂无
暂无

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

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