Developer_world
Developer_world

Reputation: 155

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

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

Upvotes: 0

Views: 5731

Answers (2)

Developer_world
Developer_world

Reputation: 155

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

Upvotes: 4

taketheleap
taketheleap

Reputation: 97

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

Upvotes: 0

Related Questions