Using WP themes in non-WP site/script (2 posts)

  1. nyenius
    Posted 11 years ago #

    Hi guys, to the point, currently I'm working on my own news management script. And coz of my curiousity, I want to make one variant of my script to be WordPress Styled one (not the code, but the way how the script works). May I do that? And may I use some WP theme in it?

    Thanks :)

  2. Kafkaesqui

    Posted 11 years ago #

    I'm not completely sure about your question, but if you're *specifically* asking if you can use the theming features in WordPress in other PHP, non-WP scripts and documents, the answer is "maybe".

    If your script is not tied to another database connection (or the connection can be switched off and on as required), all you need is to place the following in the PHP document to access any WordPress feature, including theming:

    define('WP_USE_THEMES', false);

    Note the define for the WP_USE_THEMES constant. Setting it to true overrides the functionality in your page/script and just passes management to the active theme (not what you want), so here it's set to false so you can manually include theme elements (as in get_header(), get_sidebar() and get_footer()). You can also leave out the define for the same effect.

    If for whatever reason you're unable to WordPress-enable a PHP file you could use PHP includes to insert theme templates, but any WP functions within them would fail to work.

Topic Closed

This topic has been closed to new replies.

About this Topic