0

The Problem

My website has some JavaScript and PHP that I include on each page to allow login and cookie processing for persistent login, using a header that changes if the user is logged in, and these work successfully. I would like to add a pages that contain WordPress blogs/forums, while keeping my header and all its processing at the top. Is there any way to do this? My understanding is that WordPress controls the entire page with its own <head> and <body> tags and info. The backup plan is to have the blog/forum pages be somewhat rogue pages with a separate header that links back to the main site.

What I've Tried

  1. Figure out where WordPress sends the HTML and modify that page: They use a network of include() statements to decide what to show, and I'd be concerned that a change in the WordPress admin panel would overwrite changes I make, or that the WordPress control panel code makes changes by adding code before/after a certain line, and I'd somehow break that.
  2. Put the blog pages in an iframe: Prevents blog permalinks and seems to undercut the SEO benefit of a blog. Even if I could get around this with some kind of .htaccess hackery, I'm concerned having the page in an iframe could cause browsers to block some WordPress functions for security reasons.

Code I Want To Include

  1. session_start(), cookie handling and database connect in PHP at the top
  2. A header just after <body> that I include using <?php include('header.php')?>
  3. headerProcessing.js script that I include in the head tag (along with jquery)
  4. CSS file for header styling

I'm stumped and can't seem to find anything with Google - any help appreciated. Thanks!

4
  • Wordpress doesn't "hijack" anything... it dynamically creates its own pages. If you want the Wordpress generated pages to look the same as pages in your existing website, then you simply need to create your own Wordpress "theme". There is endless documentation about how to do this. There are even bare-bones starter themes that you can copy & edit. Commented Jul 15, 2013 at 18:01
  • A fair objection - I've changed "hijacks" to "controls", which is more neutral. And I recognize that that's good for more common use cases, especially blogs by non-tech people. But I need to add custom code and JavaScript that calls pages that interact with my database, which is different from just trying to use WordPress to get it to "look" the same. Commented Jul 16, 2013 at 15:38
  • My comment had nothing to do with semantics. Wordpress does not "control" your page either. If you're on a Wordpress page, then that page was dynamically created with Wordpress. If you're on some other page outside of Wordpress, then it does nothing. Commented Jul 17, 2013 at 15:33
  • As far as my suggestion that you learn about creating a custom Wordpress theme, I can see you did not fully investigate. In order for you to get your Wordpress page to "look" like your own site's pages, there is PHP, JavaScript as well as HTML & CSS, so I see no reason why you cannot incorporate your custom code into a Wordpress theme. (Wordpress is built with PHP in case you did not know.) Commented Jul 17, 2013 at 15:34

1 Answer 1

-1

You'd be better off to join WordPress as opposed to fighting it.

WordPress provides dozens of ways to access and manipulate page content. The easiest of which is to add hooks to wp_head and wp_footer in your theme's function.php.

I'd also encourage you to read about WordPress Theme Development.

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

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.