I have this code:

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

      $dom = new domDocument;
      $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?

  • I assume that line 6 is this one: $dom->loadHTML($content); ?
    – s_ha_dum
    Apr 17 '13 at 13:25
  • That's correct.
    – Mentalhead
    Apr 17 '13 at 13:26
  • What does var_dump($content); tell you? Add that as the first line inside the function.
    – s_ha_dum
    Apr 17 '13 at 13:30
  • null string<html code></html code>...(length=805)
    – Mentalhead
    Apr 17 '13 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.
    – s_ha_dum
    Apr 17 '13 at 13:45

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, privacy policy and cookie policy

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