Support » Themes and Templates » Integrate WordPress into an Existing Website

  • A while back I created my own blog engine which worked for me at the time, however I can now see that it does not “cut the mustard” in todays modern blogging world.

    I have decided to integrate WordPress into my site. I have created a new theme and followed these very good instructions from Jonathan Wold:

    I do have one problem though:

    My existing php site uses global variables for various tasks, one of which is an internal page id used whenever I need to pickup page specific data. On my pages with wordpress content, I cannot access any of my globals from within a function.

    As a test and to illustrate clearer, this code is in my themes header file: (mysiteheader.php sets up all the global variables and outputs header, nav bar etc).

    include “mysiteheader.php”;

    echo “[” . $internalPageID . “]”;

    function testFunction()
    global $internalPageID;
    echo “[” . $internalPageID . “]”;


    Results in a page with navigation as expected and the following text:


    indicating that internalPageID is not within the scope of the testFunction.

    Has anybody experienced this before or know of a workaround? Is there some sort of directive that wordpress uses which disables global?

    Thanks in Advance


Viewing 1 replies (of 1 total)
  • Is it that the theme header is called as a fuction, so the variables aren’t global? Try putting another global $internalPageID right at the top of the header file.

    I use a few global variables, so they aren’t completely disabled.

Viewing 1 replies (of 1 total)
  • The topic ‘Integrate WordPress into an Existing Website’ is closed to new replies.