2

管理パネルで定義される wordpress ダッシュボードにカスタム コンテンツを追加するための最良の方法を見つけようとしています。

したがって、基本的に、管理者アカウントで特定の設定を設定できるようにし、他のユーザー (購読者、編集者など) がログインするとカスタム ダッシュボードが表示されます (管理者にも表示されます)。

これまでのところ、ダッシュボード全体をクリアし、ウィジェットを追加する方法を知っていますが、代わりに (ウィジェット ボックスなしで) カスタム html を追加しようとしています。

提案/アイデアはありますか?私はこれについていくつかの助けが欲しいです、ありがとう!

4

2 に答える 2

3

functions.phpおそらく、次のような特定の HTML コンテンツでカスタム関数を簡単に追加できます。

/* add content */
function customContent() {
  echo '<div><p>Custom Lorem Ipsum Content</p></div>';
} 

/* add action */
add_action('load-index.php', 'customContent');

この流れで、ダッシュボード内の管理バーの下にいくつかの customContent をすべてのユーザーに表示しています。しかし、今ではスタイリングを行うのはかなりの作業になります. では、通常の customDashboardWidgets とその機能を使用して、スタイリングをリセットしてみませんか?

/* add content */   
function customContent() {
  echo '<div><p>Custom Lorem Ipsum Content</p></div>';
}

/* add widget */
function add_customDashboardWidget() {
  wp_add_dashboard_widget('wp_dashboard_widget', 'Custom Content', 'customContent');
}

/* add action */
add_action('wp_dashboard_setup', 'add_customDashboardWidget' );

最後に、スタイリングを行うことができます。

<style type="text/css">
.postbox,
.postbox div.handlediv,
.postbox h3.hndle {
  background: none;
  border: none;                       
}                       
</style>

注: CSS 内にスタイルを挿入する場合は、CSS の前後の PHP タグを正しく閉じたり開いたりしてください。functions.php

于 2012-12-09T08:40:34.287 に答える
0

以下の関数は、ダッシュボードからいくつかの不要なボックスを削除します。また、「ヘルプとサポート」というカスタム ボックスを追加します。このセクションには任意の html を追加できます。

以下のコードをfunctions.php

//Remove unwanted boxes and Add a custom widget called 'Help and Support
function my_custom_dashboard_widgets() {
   global $wp_meta_boxes;
   unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
   unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
   unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
   unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
   wp_add_dashboard_widget('custom_help_widget', 'Themes: Help and Support', 'custom_dashboard_help');
}
function custom_dashboard_help() {
    echo '<p>Support: <a href="#" target="_blank">Support Forum</a><i> (For members only).</i><p><p>Wants to customize your theme by our WordPress Experts? <a href="#" target="_blank">Customize my theme</a> <i>(Our wp Experts will do it for you!)</i></p>';
}

これがお役に立てば幸いです。

于 2012-08-03T05:39:55.807 に答える