WordPress.org

Ready to get started?Download WordPress

Forums

Integrate WordPress into an Existing Website (2 posts)

  1. lonewolfonline
    Member
    Posted 7 years ago #

    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: http://www.jonathanwold.com/tutorials/wordpress_integration/

    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).

    <?php
    include "mysiteheader.php";

    echo "[" . $internalPageID . "]";
    testFunction();

    function testFunction()
    {
    global $internalPageID;
    echo "[" . $internalPageID . "]";
    }

    ?>

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

    [blog][]

    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

    Tim

  2. jrawle
    Member
    Posted 7 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic