WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I created a plugin in order to replace some content in the post with information from a xml file. To parse the file I'd like to use xml2ary and the wp_insert_post_data filter. I got the content replacement working with a teststring and I can also parse the xml in a script outside of WordPress. But when I try to call

$data = xml2ary(file_get_contents($url));

inside of the plugin, I get the following error, twice:

Warning: mysql_real_escape_string() expects parameter 1 to be string, array given in {path}\testblog\wp-includes\wp-db.php on line 774

plus another one:

Warning: Cannot modify header information - headers already sent by (output started at {path}\testblog\wp-includes\wp-db.php:774) in {path}\testblog\wp-includes\pluggable.php on line 934

Here's my plugin code:


if (!class_exists("Marketplace")) {
class Marketplace {

    function Marketplace(){

        add_filter( 'wp_insert_post_data' , 'addInfo' , '99', 2 );

     if (class_exists("Marketplace")) {
$marketplace = new Marketplace();

     if (isset($marketplace)) {

function addInfo( $data, $postarr ){    

$url = "http://catalog.zune.net/v3.2/de-DE/apps/578ef361-c265-46b7-b6f4-63cbd7fbefe0?clientType=WinMobile%207.0";
$data = xml2ary(file_get_contents($url));

$data["post_content"] = "test";
$data["post_content filtered"] = "test";
return $data;


Any idea why this is happening?

share|improve this question
up vote 0 down vote accepted

Of course I shouldn't save my XML Array in $data. -.-

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.