0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

WordPressのtagの見かけをjQueryでいじってみた

Last updated at Posted at 2015-01-14

WordPressの「00_」から始まるtagに打ち消し線をつけて、頭に「CLOSE:」をつけるjQuery。

うちのテーマ(Graphene)はheadに書き込みできるオプションが用意されているので、軽い気持ちでやってみました。
「タグの更新は止まっているのだけどリンクは残す」という処理をしたかったのでこんな記述をしました。
「00_」にしたのはCTCの「名前ソートの降順」で下に固めるため。

jQuery(function($){
   $('a.ctc-tag').each(function(){
        if($(this).text().match(/^00_/)){
            $(this).parent().prepend("CLOSE:");
            $(this).css("text-decoration","line-through");
            $(this).text($(this).text().split("00_")[1]);
        }
    });
});

「CLOSE:」をaタグの中には入れたくなかったので、親まであがってprependしました。

なお、このテーマ(Graphene)のオプションに2バイト文字を入れると、管理画面に再表示するときに文字化けが発生したりして、管理画面がおかしくなる恐れがあったので、2バイト文字を使っていません。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?