0

I have added a folder (json) to wp-includes with a file inside called users.json. I am trying to write to this file but am getting the following error:

failed to open stream: HTTP wrapper does not support writeable connections

I have been referencing it like the following in my php:

$file = "http://www.fakeurl.com/wp-content/json/users.json";

I believe I need to reference as per the name on the server. Is there a built in way to get this in wordpress?

Something like <?php echo get_template_directory_uri(); ?>

1 Answer 1

3

You sad you put the json in wp-includes, but in the url you wrote wp-content. So I give you the code for getting the server path for both folders:

// wp-includes
$file = ABSPATH . WPINC . '/json/users.json';

// wp-content
$file = WP_CONTENT_DIR . '/json/users.json';

You can find many WordPress constants (like ABSPATH, WPINCand WP_CONTENT_DIR on http://wpengineer.com/2382/wordpress-constants-overview/

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.