2017-10-12 19 views

答えて

0

[OK]を、私はあなたが100%右を得るかどうかわかりません...あなたはデフォルトの "ポスト"の名前と外観を変更!

は、多分そのためのカスタムポストタイプを導入し、より良いされていましたが、前に言ったように、あなたのclinetがそのようにそれを望んでいるならば、それはここでは、

...サブメニューの問題を変更しません。私たちは、私はこのソリューションをテストし、それが正常に動作し、行く、もちろんあなたには、いくつかのスタイリングをしなければならないことがあります。

function load_custom_wp_admin_style() { ?> 
<script> 
    jQuery("#menu-posts ul li:nth-of-type(4)").prependTo("#adminmenu"); 
    jQuery("#menu-posts ul li:nth-of-type(4)").prependTo("#adminmenu"); 
</script> 
<?php } 
add_action('admin_footer', 'load_custom_wp_admin_style'); 

私は自分のfunctions.phpにこのコードを追加し、これは「カテゴリ」との「タグ」を移動しました「ダッシュボード」の直前に管理者メニューのトップに「投稿」を投稿してください!

あなたは、「ダッシュボード」を使用しようとした後にそれをしたい場合:あなたはそれを見て、あなたはセレクタ「#メニュー-投稿を」変更する必要がありますポストタイプ「ポスト」を使用していない場合

function load_custom_wp_admin_style() { ?> 
<script> 
    jQuery("#menu-posts ul li:nth-of-type(4)").insertAfter("#menu-dashboard"); 
    jQuery("#menu-posts ul li:nth-of-type(4)").insertAfter("#menu-dashboard"); 
</script> 
<?php } 
add_action('admin_footer', 'load_custom_wp_admin_style'); 

インスペクタでアップ! YOUR LASTのコメントに係る

EDIT:あなたはWordPressのコア管理-CSSを変更していないいくつかのスタイリングをしたい場合は

、あなたはすべてのワードプレスの更新時にこれらの変更を失うことになります!

function load_custom_wp_admin_style() { ?> 
    <script> 
     // I add an id to the element so it can be selected more easily for styling...  
     jQuery("#menu-posts ul li:nth-of-type(5)").attr('id', 'custom_tag_link'); 
     // Here I change the position as done before... 
     jQuery("#menu-posts ul li:nth-of-type(5)").insertAfter("#menu-dashboard"); 

     jQuery("#menu-posts ul li:nth-of-type(4)").attr('id', 'custom_cat_link'); 
     jQuery("#menu-posts ul li:nth-of-type(4)").insertAfter("#menu-dashboard"); 
    </script> 
    <style> 
     /* Here comes the styling... */ 

     /* Do some margins/paddings and background-alignments... */ 
     #custom_cat_link, #custom_tag_link { 
      background-size: auto 100%; 
      background-repeat: no-repeat; 
      padding-left: 25px !important; 
      margin: 10px !important; 
     } 

     /* Set your Icons here... */ 
     #custom_cat_link { 
      background-image: url('https://cdn0.iconfinder.com/data/icons/customicondesignoffice5/256/examples.png'); 
     } 
     #custom_tag_link { 
      background-image: url('https://cdn0.iconfinder.com/data/icons/customicondesignoffice5/256/examples.png'); 
     }  
    </style> 
<?php } 
add_action('admin_footer', 'load_custom_wp_admin_style'); 

二つ目:

しかし、あなたはあなたの関数を経由してのスタイルを挿入することができ、我々は、スクリプトを挿入するので、すなわち、このようなCSSの背景を経由してアイコンを追加しましたように同じ方法で、CSS名前の変更を...前に述べたように、私はポストタイプを「ポスト」に変更していないでしょう。より良いプラクティスは、カスタムポストタイプを導入することでした。あなたは望みどおりに名前を付けることができますし、タクソノミーも変更できます。それでは、今度もまた、私たちはJSで「汚れたハック・ア・様」な道を行く...全コード:

function load_custom_wp_admin_style() { ?> 
    <script> 
     // I add an id to the element so it can be selected more easily for styling...  
     jQuery("#menu-posts ul li:nth-of-type(5)").attr('id', 'custom_tag_link'); 
     // Change the name of the <a>-element in the <li>-elem here... 
     jQuery("#menu-posts ul li:nth-of-type(5) a").html('NEW TAG TITLE'); 
     // Here I change the position as done before... 
     jQuery("#menu-posts ul li:nth-of-type(5)").insertAfter("#menu-dashboard"); 

     jQuery("#menu-posts ul li:nth-of-type(4)").attr('id', 'custom_cat_link'); 
     jQuery("#menu-posts ul li:nth-of-type(4) a").html('NEW CAT TITLE'); 
     jQuery("#menu-posts ul li:nth-of-type(4)").insertAfter("#menu-dashboard"); 
    </script> 
    <style> 
     /* Here comes the styling... */ 
     /* Do some margins/paddings and background-alignments... */ 
     #custom_cat_link, #custom_tag_link { 
      background-size: auto 100%; 
      background-repeat: no-repeat; 
      padding-left: 25px !important; 
      margin: 10px !important; 
     } 

     /* Set your Icon here... */ 
     #custom_cat_link { 
      background-image: url('https://cdn0.iconfinder.com/data/icons/customicondesignoffice5/256/examples.png'); 
     } 
     #custom_tag_link { 
      background-image: url('https://cdn0.iconfinder.com/data/icons/customicondesignoffice5/256/examples.png'); 
     }  
    </style> 
<?php } 
add_action('admin_footer', 'load_custom_wp_admin_style'); 

ここでは、アクションで全体を見ることができます:

working example

+0

Ups、私はちょうどこのようにカテゴリとタグの順番を変更しました。これを避けてください:jQuery( "#menu-posts ul li:nth-​​of (5) ")。insertAfter("#menu-dashboard ");jQuery( "#menu-posts ul li:nth-​​of-type(4)")。insertAfter( "#menu-dashboard"); – ToTaTaRi

+0

非常に助けていただきありがとうございます...私はwp-admin/css/admin-menu.cssでそれをやろうとしているので、アイコンを追加してフォントを編集する方法があるのでしょうか? –

+0

もう1つ重要なこと:名前を変更する方法は? –

0

ので、たとえば、あなたはメニューが表示されますどのように高い変えることができますが、私はあなたがサブメニューのレベルを変更することはできませんことをかなり確信していますカテゴリはすべてのタクソノミーが定義されている投稿タイプに属しているので、ポストタイプ "投稿"に属します。

多分あなたが行うことができます、あなたがotionページ、またはカスタムポストタイプを設定することができますが、最初のものはまた、単にサブメニューとして、直接のタクソノミーと第二のものではないがinculdeません...とにかく

ですから、管理画面のDOMを変更するJavaスクリプトのハックでは、私はそうすることを勧めません!その仕事の具体的な理由はありますか?

+0

ここでは、管理画面上でカスタムJSを含める方法を見ることができます。 ます。https://codex.wordpress .org/Plugin_API/Action_Reference/admin_enqueue_scripts リンクを「移動する」スクリプトを追加することもできます。つまり、jqueryを使用することができます。しかし、私の意見では、このことはお勧めできません。あなたの答えは – ToTaTaRi

+0

です。私は以下のように説明しています。 –

関連する問題