Skip to content

Instantly share code, notes, and snippets.

@s-hiroshi
Created June 29, 2012 06:54
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 s-hiroshi/3016365 to your computer and use it in GitHub Desktop.
Save s-hiroshi/3016365 to your computer and use it in GitHub Desktop.
WordPress > shortcode > bloginfo
<?php
/**
* 入力エディタでbloginfoを取得する。
* @param arg bloginfoの引数
* url ブログのURL
* template_directory テンプレートディレクトリのパス
* stylesheet_directory テーマディレクトリのパス
* デフォルトではblogのURLを返す
*/
function bloginfo_func($atts) {
extract(shortcode_atts(array(
'arg' => "url"
), $atts));
if ('' !== $arg) {
$value = get_bloginfo($arg);
} else {
$value = get_bloginfo('url');
}
return $value;
}
add_shortcode('bloginfo', 'bloginfo_func');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment