Integrating Wordpress into a non-wordpress Site

Hi – this tip is for anyone using both wordpress and non-wordpress pages on the same site.

If you’d like to use a wordpress plugin on non-wp pages, or have anything in functions.php tell the non-wp pages what to do – e.g. display a different result from amazon depending on which folder they’re in (see If you're in this folder then display this) – then on all the non-wordpress pages:

(1) add this at the top before doctype:

<?php require '../wp-blog-header.php';
status_header(200);
nocache_headers();
?>

where “…/” is the path to root folder (public_html) where wp-blog-header.php is.

(2) add this in last line before you close </head>

<?php wp_head(); ?><!--enables js+css to load for wp plugins-->

(3) add this before you close </body>

<?php wp_footer(); ?><!--enables js+css to load for wp plugins-->

Some sites and even codex (http://codex.wordpress.org/Integrating_WordPress_with_Your_Website) will tell you to just add this at the top (in addition to wp_head & wp_footer):
<?php require '../wp-blog-header.php';?>

BUT if you do this (leave out the status_header and nocache lines) then WP will return a 404 error on the non-WP pages to bots like googlebot and xml-sitemaps. Essentially all your non-WP pages become invisible to googlebot. Only user browsers will still see them.

WP thinks that the non-WP page is a WP internal URL (because of wp-blog-header) and after it cannot find it internally, returns status code 404 although the page loads fine. So a human being sees it, but a bot sees the 404.

I learned the hard way!

– Val

That’s interesting and I will try it out sometime, but I don’t really understand in what situation you would use this. What do you mean by a non-WordPress page?

Wouldn’t it just be easier to have a WordPress site that contains both static and dynamic pages, with their headers, footers and skeleton structures always the same?. The difference comes basically in the content area where the ‘non-WordPress’ page would have static html instead of a loop to pull in content from the database. This seems to me to be much less complicated.

Hi - a non-wordpress page is a page written in html or php, not in wordpress.

I just posted that tip for google to pick up for people like myself who’ve built up a site over years – starting long before wordpress ever came on the scene! – and who are searching for a way to integrate wordpress plugins or functions.php into the non-wordpress pages of their site. For us, it’s just too much hassle to move over two decades of work into wordpress! But at the same time wordpress has some cool things - like a testimonials plugin - which are great to use.

Not if your site already has 2000 pages before you add WordPress.

I recently converted a 100 page non-WordPress site to WordPress and just converting the pages took about 25 hours once I made the changes needed for them to work properly in WordPress - particularly the ones with complex PHP or JavaScript in them.

True. But then I’ve never dealt with a site that has 2000 pages, but in that case something like what @valarcher suggestd would be the way to go.

Thanks guys for detailing what non-wordpress means so google is more likely to pick this up! Also I see an error in my original post, it should read like this:

(2) add this in last line before you close </head>

<?php wp_head(); ?>

(3) add this before you close </body>

<?php wp_footer(); ?>

Fixed. (You need to add a single backtick ` before and after inline code to get it to show up.)

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.