web-dev-qa-db-ja.com

Wordpressがbloginfo変数を上書きする

Wordpressでbloginfo変数をオーバーライドするにはどうすればいいですか?

たとえば、これを置き換えます。

<?php bloginfo('stylesheet_directory'); ?>

http://mysites.com/hello/のようなカスタムURLを返す

1
verhogen

上記の例では、stylesheet_directoryフックにフィルタを追加できます

add_filter('stylesheet_directory','change_stylesheet_dir') ;

function change_stylesheet_dir($stylesheet_dir, $stylesheet, $theme_root) {
  # do stuff - change the stylesheet directory
  $new_stylesheet_directory = 'http://mysites.com/hello/';
  return new_stylesheet_directory ;
 }

Bloginfoの他のパラメータについては、wp-includes/general-template.phpにあるbloginfoのコードを調べることができます。他のbloginfoパラメータに対する呼び出しに従って、それに対するフィルタがあるかどうかを確認してください。

3
anu