Skip to content

Instantly share code, notes, and snippets.

@snoise
Created January 30, 2014 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snoise/8711459 to your computer and use it in GitHub Desktop.
Save snoise/8711459 to your computer and use it in GitHub Desktop.
「特定のタグ」の記事のタイトルに文字列を追加してみるwordpressプラグイン
<?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