Created
January 30, 2014 15:47
-
-
Save snoise/8711459 to your computer and use it in GitHub Desktop.
「特定のタグ」の記事のタイトルに文字列を追加してみるwordpressプラグイン
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: paka3 Title Tag Add String | |
Plugin URI: http://www.paka3.com/wpplugin | |
Description: 「特定のタグ」の記事のタイトルに文字列を追加してみる | |
Author: Shoji ENDO | |
Version: 0.1 | |
Author URI:http://www.paka3.com/ | |
*/ | |
//15 | |
function paka3_TitleTagAddStr($title, $post_ID){ | |
if(is_single($post_ID) ){ | |
//表示するタグを指定する | |
$tag = "タグテスト1"; | |
foreach(get_the_tags() as $tags){ | |
//一つでも見つかれば離脱 | |
if($tags->name == $tag){ | |
$str = "【WordPress1日1プラグイン】"; | |
return $title.$str; | |
} | |
} | |
} | |
//条件に合わない場合はそのまま返す | |
return $title; | |
} | |
add_filter('the_title','paka3_TitleTagAddStr',10,2); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment