サポート » 使い方全般 » currentクラスの位置

  • 解決済 berghilo

    (@berghilo)


    いつもこのフォーラムではお世話になります。

    WordPress2.9.1を使用しております。
    現在表示中のページは、
    ページは current_page_item
    カテゴリーは current-cat
    が <li>の中に表示されますが、これをCSSの都合上、後続する<a>の中に入れたいのですが、どのように行えばよろしいでしょうか。

    <li class="page_item page-item-69 current_page_item"><a href="http://○○○.jp/links" title="リンク集">リンク集</a></li>

    <li class="page_item page-item-69"><a href="http://○○○.jp/links" title="リンク集" class="current_page_item">リンク集</a></li>
    のようにしたいのです。

    どなたかご教授頂けないでしょうか。
    何卒、よろしくお願いします。

2件の返信を表示中 - 1 - 2件目 (全2件中)
  • functions.phpに以下を追加するのが、最も簡単かと。

    function my_list_cats($html){
      return str_replace(' current-cat"><a ', '"><a class="current-cat" ', $html);
    }
    function my_list_pages($html){
      return str_replace(' current_page_item"><a ', '"><a class="current_page_item" ', $html);
    }
    add_filter('wp_list_categories', 'my_list_cats');
    add_filter('wp_list_pages', 'my_list_pages');

    class属性の位置が許容できないかも、ですが。

    トピック投稿者 berghilo

    (@berghilo)

    kurosquareさん、早速のご返信ありがとうございます。
    functions.phpに追加したところ、思い通りのデザインになりました!!
    大変、ありがとうございます。
    大感謝です。
    また何かありましたらよろしくお願いします。

2件の返信を表示中 - 1 - 2件目 (全2件中)
  • トピック「currentクラスの位置」には新たに返信することはできません。