using WP API outside of WP site
-
I run WP on a windows server, installed on c:\wordpress.
I have another web site whose root directory is c:\mysite.
I found this sample code in different blogs to integrate WP in my site:
<?php // Include WordPress define('WP_USE_THEMES', false); require('c:\wordpress\wp-load.php'); /* check if user is connected */ if ( is_user_logged_in() ) { echo 'Welcome, registered user!'. '<br />'; } else { echo 'Welcome, visitor!'. '<br />'; ?>
When I put this code in a test file “c:\wordpress\test.php”, it works, I only see ‘Welcome, registered user!’ or ‘Welcome, visitor!’ in my browser.
When I put this code in another test file “c:\mysite\test.php”, it does not work, I see my WP site home page.
Where did I go wrong?
- The topic ‘using WP API outside of WP site’ is closed to new replies.