几天前,我正在寻找方式使用我的自定义PHP的WordPress的网站,我在这里找到答案:How to add a php page to Wordpress。
试过几个例子,它们对每个例子都很好。但后来我想更进一步,并在wordpress页面中使用PHP图像处理。它(只使用此代码)在普通的PHP网站的作品,但是当我尝试在worpress使用它我得到错误:添加PHP文件到wordpress - Header()已经发送
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\wordpress\wp-content\themes\twentyeleven\header.php:13) in C:\xampp\htdocs\wordpress\wp-content\themes\twentyeleven\mynewsite.php on line 26
我的代码我试图使用方法是:
<?php
$dest = imagecreatefrompng('image1.png');
$src = imagecreatefromjpeg('image2.jpg');
imagealphablending($dest, false);
imagesavealpha($dest, true);
imagecopymerge($dest, $src, 10, 9, 0, 0, 181, 180, 100); //putting one image on top of other
header('Content-Type: image/png');
imagepng($dest);
imagedestroy($dest);
imagedestroy($src);
?>
那么我知道问题是我想在这里发送标题,但我不知道如何解决它。
我试着将这个标题移动到文件的顶部,但整个worpress站点不加载。
header('Content-Type: image/png');
get_header(); //<-- part of wordpress template, cant get rid of it, cuz it ruins whole site look.
所以看起来像get_header();这在某种程度上是“问题”。
尝试使用ob_start(),刷新,干净等,但后来我得到我想要的图像,没有worpress网站加载。我用尽了选项,其中没有解决了我的问题。
我的问题是:如何发送这个头,使其工作的辩论,因为没有它,我看到一些奇怪的符号代替PNG图片(像我会用记事本打开PNG图片)
任何帮助表示赞赏。
不幸的是,我不是这种情况。那么,我的文件中没有空格/换行符,但是不可能搜索所有的wordpress文件。 – Kedor 2012-07-06 09:47:24