I am using wordpress and I normally use:

if (!is_user_logged_in()){
   //something here

to detect if the wordpress user is logged in or now.

My problem is that I need to detect if the user is logged in to wordpress from a non-wordpress page.

My page is in the same directory as the other wordpress pages but is not page of wordpress.

How can I detect this from my page?

2 Answers 2


Simply place

define( 'WP_USE_THEMES', false );
include 'wp-load.php';

on to of your template files (before everything else). This loads the whole WP core.


this is untested by me, but please have a look at this article: Integrating Wordpress into an Existing Site

In essence I believe that if you use:

<?php require('/the/path/to/your/wp-blog-header.php');?>

..at the top of you (php) page you should be able to take advantage of the is_user_logged_in() function.

  • Hi, I'm new to Stack Exchange in general, so is there a way I can see why a post is voted down? Presumably this didnt work, or did I not include enough info? Commented Feb 3, 2012 at 17:21
  • Normally the downvoter should leave a reply, but they're not forced to.
    – kaiser
    Commented Feb 3, 2012 at 23:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.