Aug
23

Put wordpress on a site with an existing page.

Author Chris Cummings    Category PHP, Wordpress     Tags

So I had this site that already had a page up.  I needed to install wordpress in the root and make some changes but I didn’t want wordpress to be live to the general public…after asking in 4 forums and not getting help I figure this out.  I was thinking I should use .htaccess but I solved this with a stand alone page and a cookie checker added to the themes header.php

Here’s the good:

  1. Moved my current page from www.site.com to www.site.com/sub/
  2. Created a page accessible only to me on the site that sets and destroys a cookie in the root directory using something like this:
    $action = $_GET['action'];
    if ($action == "create")	{	setcookie("dealvilletempcookie123", "yes", time()+(60*60*24*365),"/");			}
    if ($action == "destroy")	{	setcookie("dealvilletempcookie123", "no", time()+(60*60*24*365),"/");				}
  3.  

  4. In the header.php file of the WP theme I check the cookie.
    If its set to YES then I do nothing (which opens the WP install in the root directory)
    If its set to NO (or not set or set to anything else) then I use the PHP header function to redirect…do this at the very top of the header file, before you load an WP stuff.  ITS THE LAW! :-)

Whoop…there it is.

Post comment

You must be logged in to post a comment.