Page 1 of 1

Why?include wp-load with simple_html_dom have conflict.

Posted: Fri Jul 29, 2011 8:02 pm
by techcai
Why is this 'include('wp-load.php')' with 'include('simple_html_dom.php')' will have a conflict???

include 'wp-load.php' for run function wp_insert_post($post) ,
but once include 'wp-load.php' ,the parse function can not to run that in 'simple_html_dom.php'.

Code: Select all

<?php
//include('wp-load.php'); //include 'wp-load.php' for run function wp_insert_post($post) 
include('simple_html_dom.php'); 

$post = array();
$post['post_status'] = 'publish';
$post['post_author'] = 1;
$post['comment_status'] = 'closed';
$post['post_title'] = '';
$post['post_content'] = '';
$post['post_date'] = date('Y-m-d H:i:s',strtotime("now"));

$parseURL = 'http://www.tradebit.com/visit.php/71080/product/-/87837706';
$html = new simple_html_dom(); 
$html->load_file($parseURL); 
$title = $html->find("title", 0);
$title = explode(" - ", $title->plaintext);
$post['post_title'] = $title[0];
$post['post_content'] = $html->find('div[class=orangeContent]',1); 

echo '$post post_content ' . $post['post_content'] . '<br>';
echo 'title' . '<br>';
echo $post['post_title'] . '<br>'; 

wp_insert_post($post);

$html->clear();
unset($html);

?>