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问题 –