下面是一个仪表板小部件,您可以使用它来管理它们:
// add dashboard widget
add_action(\'wp_dashboard_setup\', \'wpse_dashboard_widget\');
function wpse_dashboard_widget() {
// only show widget to users who can publish pages
if(current_user_can(\'publish_pages\')) {
wp_add_dashboard_widget(\'deduped_dash_widget\', \'Publications\', \'wpse_create_deduped_dash_widget\');
}
}
// widget contents
function wpse_create_deduped_dash_widget() {
// select publications without duplicates by using DISTINCT
global $wpdb;
$mentions = $wpdb->get_results("SELECT DISTINCT meta_value FROM wp_postmeta WHERE meta_key = \'press_mention_information_publication-name\'");
// if any were found
if($mentions) {
// display them in an unordered list; could do <ol> if you want numbers
echo \'<ul>\';
foreach($mentions as $publication) {
echo \'<li>\' . $publication->meta_value) . \'</li>\';
}
echo \'</ul>\';
}
}
如果有自定义主题或自定义子主题,可以将其放置在
functions.php
. 否则,您可以创建一个插件,这可能比只为这个小部件创建子主题更容易。
或者,如果您有权访问phpMyAdmin,则可以运行查询
SELECT DISTINCT meta_value FROM wp_postmeta WHERE meta_key = \'press_mention_information_publication-name\'
并获得列表。