• therealmixmaster

    (@therealmixmaster)


    Hello all,

    I am developing a website which has many features written in PHP, one of which is a blog. I thought that instead of writing boring blog code I could use an existing application, so I chose to download WordPress.

    I installed it and had a good play around with it for a number of hours but I’m stumped on trying to integrate it as part of my website, really. What I don’t understand is why only index.php works with get_header() and get_footer() functions… and you can’t link to other pages that you put in your theme folder without including “/wp-content/themes/(theme_name)/” in the url…

    Maybe I’m looking at this the wrong way… Does anyone have any tips on how to integrate WordPress in to an existing website?

    If WordPress doesn’t really work this way can anyone recommend a blogging application which is better designed for flexible integration in to a website.

    Thank you very much.

    Michael

Viewing 6 replies - 1 through 6 (of 6 total)
  • moshu

    (@moshu)

    Definitely, looking the wrong way πŸ™‚
    In the theme folder you place ONLY template files. If they are made as it is supposed to be – all the WP functions (like get_header) will work properly.
    What files are you trying to place into the theme folder?

    Based on your description I assume you blog is a subdir or subdomain of your site, right?
    What exactly do you mean by integrating? Styling it to look like the existing site? Having WP functions working on other partts of the website?
    Maybe if you can tell us what exactly do you want to achieve, we might be able to give more specific advice.
    Welcome to WP πŸ™‚

    Thread Starter therealmixmaster

    (@therealmixmaster)

    Thanks for the speedy reply! πŸ˜€

    What I’m trying to do is just have a page on my site that is a blog. It’s supposed to look like the rest of the existing site. But because these other pages will be feature rich I don’t want to use the WordPress “pages” technique where page content is simply taken from the database and put in to a template.

    What I’ve done is to create a WP blog and a new theme that matches my website. However, I obviously want my blog page and the other pages on the site to use the same template code. The only way I could imagine doing that is by changing the other pages, which I’ve placed in the root of the WordPress directory, to take their template from the WordPress theme folder:

    require( $_SERVER[ ‘DOCUMENT_ROOT’ ] . “/wp-content/themes/default/header.php” );

    This seems like a bad solution to me. Is there a better way. Can I not get WP to use the “templating structure” of the website as I had developed it rather than it’s own system of defining header.php and get_header() etc?

    I hope I’m making sense. If not ask questions and I’ll try to clarify.

    moshu

    (@moshu)

    Seemingly youi know more coding than I do – which is not a big deal: I know nothing πŸ™‚

    Though I might understand better how WP works. So, together we might come up with a solution.
    I’ll start with your last question:
    Can I not get WP to use the “templating structure” of the website as I had developed it rather than it’s own system of defining header.php and get_header() etc?
    Though WP is quite flexible, I guess the answer is no. Wouldn’t be easier to go the other way around? Instead of “forcing” WP to do things that it wasn’t meant for… using its features to blend it with your site?

    I am still not clear where your WP install is? I have the impression it is in the root of your site and the only problem with this: which index file will be used as the entry to your site? Renaming the WP’s index to something else will cause all kind of troubles with pagination and the permalinks.

    And about “matching” WP and non-WP files. You can make any page “WP-aware” by putting at the top of it, above everything else, this:
    <?php
    define('WP_USE_THEMES', true);
    require('./path-to-your-blog/wp-blog-header.php');
    ?>

    (and the themes part could be false or true; or just removed)
    Having that code you can use any WP function, template tags, etc. in those files.
    Does this help?

    Moderator Samuel Wood (Otto)

    (@otto42)

    ww.wp.xz.cn Admin

    When it really comes down to it, you don’t *have* to do a darned thing. Try looking at it another way.

    The page actually being executed is usually index.php (in the blog root folder). This is the starting point of the whole application. It calls the wp-blog-header.php, which does the heavy lifting. This loads the blog config file, executes the main blog functionality and loads it into memory, and then ends up calling template-loader.php.

    template-loader.php determines what sort of thing is being called and loads the proper template for it. If the template exists, then it runs. If not, then it ends up falling through to the theme’s index.php file.

    Now, the naming structure of theme’s is well defined, but ultimately only a suggestion. Parts of the blog are hardcoded to expect these filenames, but you could have the whole thing in index.php if you really wanted to. Because in the end, index.php is the main thing usually getting run. get_header(), for example, is a simple function call that loads/runs the theme’s header.php file if it exists, or the default theme’s header.php file if it doesn’t. But it’s not necessary to make that call at all, you could just put the headers stuff directly into the index.php if you wanted to. The reason it’s broken out separately is because you may have other main templates that use the same header (like single.php or what have you).

    What I don’t understand is why only index.php works with get_header() and get_footer() functions… and you can’t link to other pages that you put in your theme folder without including “/wp-content/themes/(theme_name)/” in the url…

    Because get_header() actually does this:
    load_template( TEMPLATEPATH . '/header.php');
    (load_template() actually basically only does a require_once($file);, along with some sanity checking)

    If you want to include stuff in the template folder, try using the variables like TEMPLATEPATH. It’ll make things easier.

    Thread Starter therealmixmaster

    (@therealmixmaster)

    Thanks for the replies. I’ve read over them and have a better understanding of how things work now. But now I have a new question…

    I’ve installed wordpress in:
    http://wpblog.michaelhopcroft.com

    … and want to use wordpress functions in different domains such as:
    http://me.michaelhopcroft.com

    As you can see by following the links it’s working fine but the functions that wordpress provide seem to default the links to /(the directory where I installed it)/index.php…

    To give you an example, I can display all the posts on say http://me.michaelhopcroft.com/index.php, but if I click the title of a specific post it takes me to http://wpblog.michaelhopcroft.com/index.php&#8230; I’d rather it stayed at http://me.michaelhopcroft.com/index.php.

    Is there an easy way to get it to default to the page you’re calling the functions from instead of the root of the installation directory?

    Thread Starter therealmixmaster

    (@therealmixmaster)

    Any help guys? If I’ve not made the nature of my enquiry clear please say…

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Using wordpress in an existing website’ is closed to new replies.