好的,现在我正在编辑旧问题,因为它已经完成了,但现在我有了新问题,我了解mysql查询,但不了解wordpress查询,我正在使用mysql查询,它工作得很好,但服务器速度非常慢,我知道我每页面加载大约运行30个查询,所以有没有办法在wordpress查询或其他帮助下轻松完成???
<?php $rss = fetch_feed(\'http://example.com/feed\');
if (!is_wp_error( $rss ) ) :
$maxitems = $rss->get_item_quantity(10);
$rss_items = $rss->get_items(0, $maxitems);
endif;
if ($maxitems == 0) ;
else
foreach ( $rss_items as $item ) :
$posttitle=$item->get_title();
$postcontent=$item->get_description();
$pt=mysql_real_escape_string($posttitle);
$pc=mysql_real_escape_string($postcontent);
$result=mysql_query("SELECT post_title FROM wp_posts WHERE post_title=\'".$pt."\'");
if(mysql_num_rows>0)
{
echo "hello";
mysql_query("UPDATE wp_posts SET post_title=\'".$pt."\',post_content=\'".$pc."\' WHERE post_title=\'".$pt."\'");
}
else
{
echo "hi";
mysql_query("INSERT INTO wp_posts (post_title,post_content) VALUES (\'".$pt."\',\'".$pc."\')");
}
endforeach; ?>