I'm trying to make a Wordpress plugin, therefore, I'm trying to manipulate my DOM (the post content). Currently 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' );
?>
But I always get the following error:
Empty string supplied as input
I have tried using any other custom string that has html elements and it works. Also I've tried using var_export($content, true ), and this somewhat fixes the problem, but I get errors such as:
Call to a member function getAttribute() on a non-object
What I'm I doing wrong? I'm running this script on my local computer using WAMP Server.
var_dump($content) gives me:
null
string post content (actual html that is the post) ... (length=805)
mb_find_my_imagefunction located?