1

I have this code:

<?php
function mb_find_my_image( $content ) {
    if( is_home() ) { /* if is home start */

      $dom = new domDocument;
      $dom->loadHTML($content);
      $dom->preserveWhiteSpace = false;


    } /* if is home end */
    return $content;
}
add_filter( 'the_content', 'mb_find_my_image' );
?>

However, it seems that I always get the following error:

Empty string supplied as input on line 6

What I'm I doing wrong here?

7
  • I assume that line 6 is this one: $dom->loadHTML($content); ? Commented Apr 17, 2013 at 13:25
  • That's correct. Commented Apr 17, 2013 at 13:26
  • What does var_dump($content); tell you? Add that as the first line inside the function. Commented Apr 17, 2013 at 13:30
  • null string<html code></html code>...(length=805) Commented Apr 17, 2013 at 13:33
  • 1
    That is peculiar. That does not look like any var_dump output I have seen. I expected string(123)"content content content". That null is especially interesting and do you actually have those <html code> tags or is that some kind of filler you made up? Either way, it looks like the string is not empty. Commented Apr 17, 2013 at 13:45

1 Answer 1

1

I have fixed the problem.

The main problem was that I was calling the function mb_find_my_image from index.php. After I've removed the calling from index.php, everything works as it should.

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.