Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress http错误500 featuredimages.php_Php_Wordpress - Fatal编程技术网

Wordpress http错误500 featuredimages.php

Wordpress http错误500 featuredimages.php,php,wordpress,Php,Wordpress,我想在Wordpress中启用特色图片。我添加了以下代码:添加主题支持('post thumbnails')到functions.php文件,我可以上传图像 问题是当我添加代码时:进入featuredimages.php文件,使事情变得一团糟 我开始在浏览器中遇到此错误:HTTP错误500 有人知道怎么解决这个问题吗?我有一种感觉,我必须删除Wordpress CMS之外的代码,但我还不知道如何删除。希望你能启发我/ Keith删除php开始标记中的空格 应该是这样的“ 现在函数看起来像 <

我想在Wordpress中启用特色图片。我添加了以下代码:添加主题支持('post thumbnails')到functions.php文件,我可以上传图像

问题是当我添加代码时:<?php The_post_缩略图();?>进入featuredimages.php文件,使事情变得一团糟

我开始在浏览器中遇到此错误:HTTP错误500

有人知道怎么解决这个问题吗?我有一种感觉,我必须删除Wordpress CMS之外的代码,但我还不知道如何删除。希望你能启发我/


Keith删除php开始标记中的空格

应该是这样的“ 现在函数看起来像

<?php the_post_thumbnail(); ?>


哈哈,我读了其他答案…伙计们,如果在
中使用空格,它不会导致500错误,因为(!)此文本将只是HTML代码

Keith,首先,尝试用以下代码替换您的代码:

<?php 
if( function_exists( 'the_post_thumbnail' ) ) {
    the_post_thumbnail();
} ?>

问题消失了吗

出现500错误是因为您在WordPress环境之外使用了函数。如果必须这样做,只需包含WordPress根文件夹中的wp-load.php文件即可

例如,如果featuredimages.php文件位于主题文件夹中:

<?php 
    require_once( '/../../../wp-load.php' );
    if( function_exists( 'the_post_thumbnail' ) ) {
        the_post_thumbnail();
    } 
?>


你能提供一个网站url,我可以在那里看到错误的msgwatch,删除你添加的内容直到页面正常工作,启用调试模式谢谢你提供的信息。问题现在已经解决。注册网站的人解决了问题。我感谢你的帮助。:)