Title: PHP Include Only Working When Logged In
Last modified: August 22, 2016

---

# PHP Include Only Working When Logged In

 *  [dmonaldo](https://wordpress.org/support/users/dmonaldo/)
 * (@dmonaldo)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/php-include-only-working-when-logged-in/)
 * I have been writing a custom PHP script that is included in the theme header.
   php file. The script simply connects to the database to return a couple rows 
   of data. It works successfully when I am logged into WordPress admin, but does
   not load at all when logged out and viewing the site as an anonymous user. I 
   cannot even get the script to return a basic `echo 'test';` unless I am logged
   in.
 * Has anyone ever seen or heard of this issue before? Any help would be appreciated
   so I can stop hitting my head against the keyboard.

Viewing 1 replies (of 1 total)

 *  [Advanced SEO](https://wordpress.org/support/users/jole5/)
 * (@jole5)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/php-include-only-working-when-logged-in/#post-5236733)
 * Probably your script is wrapped inside other script which checks if user is logged
   in. Try to put your script on some other place and see how it will work.

Viewing 1 replies (of 1 total)

The topic ‘PHP Include Only Working When Logged In’ is closed to new replies.

## Tags

 * [header.php](https://wordpress.org/support/topic-tag/header-php/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Advanced SEO](https://wordpress.org/support/users/jole5/)
 * Last activity: [11 years, 9 months ago](https://wordpress.org/support/topic/php-include-only-working-when-logged-in/#post-5236733)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
