WordPress提要:綜合指南
>>本教程探討了WordPress的提要功能,重點是程序化定制。 WordPress支持四種供稿格式(RDF,RSS 0.92,RSS 2.0和Atom),為最近的帖子,評論,類別,作者和搜索詞提供供稿。 這些可以通過功能訪問,消除硬編碼。
>
>支持的提要格式和訪問
> WordPress很容易支持RDF,RSS 0.92,RSS 2.0和Atom,RSS 2.0是最廣泛的兼容性。 而不是硬編碼饋電URL(例如,),將這些功能用於動態檢索:http://example.com/?feed=rss2
bloginfo('rdf_url'); bloginfo('rss_url'); bloginfo('rss2_url'); bloginfo('atom_url');
>訪問特定的提要類型
>
>或函數>
http://example.com/?feed=comments-rss2
bloginfo('comments_rss2_url');
的註釋,使用或>id
http://example.com/?p=id&feed=rss2
> post_comments_feed_link('link_text', 'post_id', 'rss2' );
類別:使用或id1
>的類別訪問for類別(ids id2
,http://www.example.com/?cat=id1,id2&feed=rss2
)。 這與標籤類似。 get_category_feed_link('id1', 'rss2');
作者:雖然WordPress缺少內置功能,但您可以以編程方式構造作者feed url:
echo '<a href="' . get_author_link(0, $authordata->ID, $authordata->user_nicename) . 'feed/">' . the_author($idmode, false) . '</a>';
http://example.com/?s=sitepoint&feed=rss2
> 在主題或插件中檢查feed請求:
is_feed()
if (is_feed()) { echo "Feed Request"; }
function disable_feed() { wp_die(__("Feed Disabled")); } add_action('do_feed', 'disable_feed', 1); add_action('do_feed_rdf', 'disable_feed', 1); add_action('do_feed_rss', 'disable_feed', 1); add_action('do_feed_rss2', 'disable_feed', 1); add_action('do_feed_atom', 'disable_feed', 1);
the_content_feed
function feed_word_count($content) { $content .= 'Total ' . str_word_count($content) . ' words'; return $content; } add_filter("the_content_feed", "feed_word_count");
>
functions.php
add_theme_support( 'automatic-feed-links' );
重定向到feedBurner(或類似服務)。 >
.htaccess
提供RSS提要
對於用戶參與仍然很有價值。 提供RSS 2.0,作者提要和評論提要可以增強用戶體驗。 提供的常見問題解答涵蓋了飼料的重要性,自定義,故障排除,SEO優化,安全性,貨幣化,績效跟踪,社交媒體集成以及創建多個提要。
以上是開發人員在WordPress中的供稿指南的詳細內容。更多資訊請關注PHP中文網其他相關文章!