0
我有WordPress和網站上的博客,在一臺機器上使用wordpress RSS。 我的想法是連接到WordPress的數據庫,並在我的網站的代碼中爲我的網站生成Rss。從wordpress數據庫生成Rss
任何想法如何做到這一點?
在WordPress的代碼,我發現
header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
$more = 1;
echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
<rss version="0.92">
<channel>
<title><?php bloginfo_rss('name'); wp_title_rss(); ?></title>
<link><?php bloginfo_rss('url') ?></link>
<description><?php bloginfo_rss('description') ?></description>
<lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate>
<docs>http://backend.userland.com/rss092</docs>
<language><?php echo get_option('rss_language'); ?></language>
<?php do_action('rss_head'); ?>
<?php while (have_posts()) : the_post(); ?>
<item>
<title><?php the_title_rss(); ?></title>
<description><![CDATA[<?php the_excerpt_rss(); ?>]]></description>
<link><?php the_permalink_rss() ?></link>
<?php do_action('rss_item'); ?>
</item>
<?php endwhile; ?>
</channel>
</rss>
但我不能只是複製的代碼在我的網站代碼。我在哪裏可以找到bloginfo_rss方法代碼?
在數據庫中,我可以找到像內容,標題字段,但我找不到描述字段和排序logick該帖子。
$this->_blogAdapter = new Zend_Db_Adapter_Pdo_Mysql(array(
'host' => 'localhost',
'username' => 'root',
'password' => 'password',
'dbname' => 'database'
));
我可以連接到我的博客,但我不知道我可以如何利用所有的字段,排序和另一個logick。任何解決它?
$帖= $這 - > _ blogAdapter->的select() - >從(陣列( 'P'=>'blog_posts '')) - > where('post_status =?','publish') - > where('post_type =?','post') - > limit($ limit) - > query() - >使用fetchall(); return $ posts; 我現在可以獲得所有帖子,但是我有utf-8和俄語單詞的uncoding問題 –