出于某些原因,比如你制作免费主题,想宣传一下自己的网站(前提是你网站的内容对用户有所帮助),也许你需要在WordPress仪表盘首页添加自己的Feed订阅,如下图所示

那你可以使用类似下面的代码来实现,添加到主题的functions.php的最后一个 ?> 的前面即可
//订阅WordPress大学
function dashboard_custom_feed_output() {
echo '<div class="rss-widget">';
wp_widget_rss_output(array(
'url' => 'https://www.wpdaxue.com/feed/', //rss地址
'title' => '查看WordPress大学的最新内容',
'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', 'WordPress大学', 'dashboard_custom_feed_output');
}
add_action('wp_dashboard_setup', 'h_add_dashboard_widgets' ); |
//订阅WordPress大学
function dashboard_custom_feed_output() {
echo '<div class="rss-widget">';
wp_widget_rss_output(array(
'url' => 'https://www.wpdaxue.com/feed/', //rss地址
'title' => '查看WordPress大学的最新内容',
'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', 'WordPress大学', 'dashboard_custom_feed_output');
}
add_action('wp_dashboard_setup', 'h_add_dashboard_widgets' );
请根据代码中的提示修改相关信息。
来源:
https://www.wpdaxue.com/dashboard-custom-feed.html
微信公众号
手机浏览(小程序)
Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(): Failed to enable crypto in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_32485.jpg): failed to open stream: operation failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57