什么';使用PHP获取Wordpress网站类别列表的正确方法是什么?
我需要阅读博客的Wordpress分类列表,并将它们作为超链接插入我的PHP页面。 我使用了simplexml\u load\u文件,它在我的本地Wamp服务器上运行得非常好。 但我担心的是,有大量用户的生产服务器的性能。我应该为生产页面进行缓存吗?怎么用?是否有其他标准解决方案什么';使用PHP获取Wordpress网站类别列表的正确方法是什么?,php,simplexml,feed,Php,Simplexml,Feed,我需要阅读博客的Wordpress分类列表,并将它们作为超链接插入我的PHP页面。 我使用了simplexml\u load\u文件,它在我的本地Wamp服务器上运行得非常好。 但我担心的是,有大量用户的生产服务器的性能。我应该为生产页面进行缓存吗?怎么用?是否有其他标准解决方案 $feed_url = "http://my.web.site/category/$category/feed/"; // If there is some errors, return empty if(! $ne
$feed_url = "http://my.web.site/category/$category/feed/";
// If there is some errors, return empty
if(! $news_xml = @simplexml_load_file($feed_url, 'SimpleXMLElement', LIBXML_NOCDATA & LIBXML_NOWARNING & LIBXML_NOERROR))
{
log_message('error','Feed load error: '.$feed_url);
return [];
}
$data = [];
foreach ($news_xml->channel->item as $news_item) {
$new_item = [
"title" => (string)$news_item->title,
"link" => (string)$news_item->link,
"comments" => (string)$news_item->comments,
"pubDate" => (string)$news_item->pubDate,
"category" => (string)$news_item->category,
"guid" => (string)$news_item->guid,
"description" => (string)$news_item->description,
];
if ($news_item->children('media', true)->content) {
$new_item["image_url"] = (string)$news_item->children('media', true)->content->attributes()->url;
}
$data[] = $new_item;
}
是的,你应该绝对缓存提要。我如何使用codeigniter实现这一点?有没有更好的解决方案来获取Wordpress类别?CodeIgniter没有什么特别之处,它只是PHP。因为你是在问关于推荐和教程的问题,所以你的问题对于这个网站来说完全是离题的,但是请检查一下,开始吧。