For parsing the strings inside my Wordpress posts to HTML. I use Simple DOM Parser. With the below code I receive Fatal error: Call to a member function find() on a non-object
. Could somebody be of helping hand?
Thanks in advance
<?php
require ('simple_html_dom.php');
/*
Template Name: Practice
*/
$query = new WP_Query( 'category_name=arthouse' );
if ($query->have_posts()) {
while ( $query->have_posts() ) {
$query->the_post();
$page = the_content().' ';
$html = str_get_html($page). " ";
foreach($html->find('div[class=post]') as $element) {
echo $element->src . '<br>';
}
}
}else{
echo 'Sorry, no posts matched your criteria.';
}
?>