0

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

4
  • So is the question - can I require header.php and footer.php by requiring single file: custom.php ? Commented Apr 21, 2015 at 13:16
  • @sitilge I want to outside from wordpress. Commented Apr 21, 2015 at 13:24
  • No problems - wp is a set of files, .php mostly. require('/path/to/file/in/wp/dir/header.php'); Commented Apr 21, 2015 at 13:27
  • @sitilge No it doesn't work. Commented Apr 21, 2015 at 13:52

2 Answers 2

4

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

Sign up to request clarification or add additional context in comments.

3 Comments

Shouldn't you include the header after the <head> tag? And It Works! should be <p>It Works!</p>
@ViperCode why should not include after header any specific reason I want to add some JS files in newer files then how I can?
Whichever one has the HTML in it should come after the </head> tag. All your scripts should be included in the <head></head>
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.