在 WordPress 的后台仪表盘中,我们可以直接查看到 WordPress 官方的 Feed 更新。同样,我们可以利用这个原理在后台仪表盘中自定义我们需要订阅的 Feed。此功能可能比较适合一些主题开发者。将以下代码添加到主题的 functions.php 文件中即可。
function dashboard_custom_feed_output() { echo '<div class="rss-widget">'; wp_widget_rss_output(array( 'url' => 'https://www.imjeff.cn/feed/', //自定义rss地址 'title' => '查看主题官网最新内容', 'items' => 6, //显示篇数 'show_summary' => 0, //是否显示摘要,1为显示 'show_author' => 0, //是否显示作者,1为显示 'show_date' => 1 )); //是否显示日期 echo '</div>'; } function h_add_dashboard_widgets() { wp_add_dashboard_widget('example_dashboard_widget', '最新动态', 'dashboard_custom_feed_output'); } add_action('wp_dashboard_setup', 'h_add_dashboard_widgets' );
发表评论