將 feed-atom.php拿來客制化 (manually changing the feed templates to meet your needs),接下來確定放置的路徑,確定後需要add_action do_feed 並 load_template,讓 Wordpress 知道位置。
function create_my_custom_posts() {
load_template(plugin_dir_path(__FILE__).'/custom_rss/custom_atom.php');
}
add_action('do_feed_custom-posts', 'create_my_custom_posts', 10, 1);
3. 如何只列特定條件的文章,例如某個分類、某個標籤:
客制化的過程中,可以取某個分類或某個標籤。
自己寫sql 來取資料 (兩個TABLE取資料):
$wp_query->request = "SELECT * FROM
( SELECT * FROM posts-1 WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 10 ) A
UNION ALL
SELECT * FROM
( SELECT * FROM posts-2 WHERE post_status = 'publish' ORDER BY post_date DESC LIMIT 10 ) B
ORDER BY post_date DESC LIMIT 10";
$pageposts = $wpdb->get_results($wp_query->request, OBJECT);