1

I'm using this code here:

<?php
$post_id = 3651;
$queried_post = get_post($post_id);
$title = $queried_post->post_title;
echo $title;
echo $queried_post->post_content;
?>

post id 3651 definitely exists, but I keep getting a server error.

The code is so simple - I looked at it many times but can't figure out what's wrong.

Am I using outdated functions or something?

2
  • HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request. Commented Oct 13, 2011 at 22:23
  • This is an apache error, I seriously doubt this code has anything to do with the code you've provided unless you've added some hooks. I would first look at your .htaccess, turn it off and see if the 500 error is removed (might break other functionality but at least you've localised the error), then ensure that the syntax is correct Commented Oct 14, 2011 at 0:28

2 Answers 2

1

Turns out I had to include this line:

require_once("../wp-blog-header.php");

Thanks for those who helped.

Sign up to request clarification or add additional context in comments.

Comments

0

Assuming Apache web server and possibly a co-located server that has error reporting turned off in its configuration and you don't have access to change it, if at least .htaccess directives are allowed and you've got the ability to set the permissions on a log file via FTP or SSH, you could create and upload a blank php_errors.log, add the following directive to your .htaccess and then refresh the page you were on that was producing the error:

php_flag  log_errors on
php_value error_log  /path/to/your/htdocs/php_errors.log

If the log file gets populated, please post the error and I'll update my answer with further assistance.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.