开发者

Simple wordpress database php query not working

开发者 https://www.devze.com 2023-04-13 02:01 出处:网络
I\'m using this code here: <?php $post_id = 3651; $queried_post = get_post($post_id); $title = $queried_post->post_title;

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 开发者_如何学GoI 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?


Turns out I had to include this line:

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

Thanks for those who helped.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号