get_bloginfo

Retrieves information about the current site.

Description

(string) get_bloginfo( (string) $show = '', (string) $filter = 'raw' ); 

Possible values for $show include:

- name - Site title (set in Settings > General) - description - Site tagline (set in Settings > General) - wpurl - The WordPress address (URL) (set in Settings > General) - url - The Site address (URL) (set in Settings > General) - admin_email - Admin email (set in Settings > General) - charset - The Encoding for pages and feeds (set in Settings > Reading) - version - The current WordPress version - html_type - The content-type (default: text/html). Themes and plugins can override the default value using the filter - text_direction - The text direction determined by the site's language. is_rtl() should be used instead - language - Language code for the current site - stylesheet_url - URL to the stylesheet for the active theme. An active child theme will take precedence over this value - stylesheet_directory - Directory path for the active theme. An active child theme will take precedence over this value - template_url / template_directory - URL of the active theme's directory. An active child theme will NOT take precedence over this value - pingback_url - The pingback XML-RPC file URL (xmlrpc.php) - atom_url - The Atom feed URL (/feed/atom) - rdf_url - The RDF/RSS 1.0 feed URL (/feed/rfd) - rss_url - The RSS 0.92 feed URL (/feed/rss) - rss2_url - The RSS 2.0 feed URL (/feed) - comments_atom_url - The comments Atom feed URL (/comments/feed) - comments_rss2_url - The comments RSS 2.0 feed URL (/comments/feed)

Some $show values are deprecated and will be removed in future versions. These options will trigger the _deprecated_argument() function.

Deprecated arguments include:

- siteurl - Use url instead - home - Use url instead

Returns (string)

Mostly string values, might be empty.

Parameters (2)

0. $show — Optional. (string) => ''
Site info to retrieve. Default empty (site name).
1. $filter — Optional. (string) => 'raw'
How to filter what is retrieved. Default raw..

Usage

  1. if ( !function_exists( 'get_bloginfo' ) ) { 
  2. require_once ABSPATH . WPINC . '/general-template.php'; 
  3.  
  4. // Optional. Site info to retrieve. Default empty (site name). 
  5. $show = ''; 
  6.  
  7. // Optional. How to filter what is retrieved. Default 'raw'. 
  8. $filter = 'raw'; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = get_bloginfo($show, $filter); 
  12.  

Defined (2)

The function is defined in the following location(s).

/wp-includes/general-template.php  
  1. function get_bloginfo( $show = '', $filter = 'raw' ) { 
  2. switch( $show ) { 
  3. case 'home' : // DEPRECATED 
  4. case 'siteurl' : // DEPRECATED 
  5. _deprecated_argument( __FUNCTION__, '2.2.0', sprintf( 
  6. /** translators: 1: 'siteurl'/'home' argument, 2: bloginfo() function name, 3: 'url' argument */ 
  7. __( 'The %1$s option is deprecated for the family of %2$s functions. Use the %3$s option instead.' ),  
  8. '<code>' . $show . '</code>',  
  9. '<code>bloginfo()</code>',  
  10. '<code>url</code>' 
  11. ) ); 
  12. case 'url' : 
  13. $output = home_url(); 
  14. break; 
  15. case 'wpurl' : 
  16. $output = site_url(); 
  17. break; 
  18. case 'description': 
  19. $output = get_option('blogdescription'); 
  20. break; 
  21. case 'rdf_url': 
  22. $output = get_feed_link('rdf'); 
  23. break; 
  24. case 'rss_url': 
  25. $output = get_feed_link('rss'); 
  26. break; 
  27. case 'rss2_url': 
  28. $output = get_feed_link('rss2'); 
  29. break; 
  30. case 'atom_url': 
  31. $output = get_feed_link('atom'); 
  32. break; 
  33. case 'comments_atom_url': 
  34. $output = get_feed_link('comments_atom'); 
  35. break; 
  36. case 'comments_rss2_url': 
  37. $output = get_feed_link('comments_rss2'); 
  38. break; 
  39. case 'pingback_url': 
  40. $output = site_url( 'xmlrpc.php' ); 
  41. break; 
  42. case 'stylesheet_url': 
  43. $output = get_stylesheet_uri(); 
  44. break; 
  45. case 'stylesheet_directory': 
  46. break; 
  47. case 'template_directory': 
  48. case 'template_url': 
  49. break; 
  50. case 'admin_email': 
  51. $output = get_option('admin_email'); 
  52. break; 
  53. case 'charset': 
  54. $output = get_option('blog_charset'); 
  55. if ('' == $output) $output = 'UTF-8'; 
  56. break; 
  57. case 'html_type' : 
  58. $output = get_option('html_type'); 
  59. break; 
  60. case 'version': 
  61. global $wp_version; 
  62. $output = $wp_version; 
  63. break; 
  64. case 'language': 
  65. /** translators: Translate this to the correct language tag for your locale,  
  66. * see https://www.w3.org/International/articles/language-tags/ for reference. 
  67. * Do not translate into your own language. 
  68. */ 
  69. $output = __( 'html_lang_attribute' ); 
  70. if ( 'html_lang_attribute' === $output || preg_match( '/[^a-zA-Z0-9-]/', $output ) ) { 
  71. $output = get_locale(); 
  72. $output = str_replace( '_', '-', $output ); 
  73. break; 
  74. case 'text_direction': 
  75. _deprecated_argument( __FUNCTION__, '2.2.0', sprintf( 
  76. /** translators: 1: 'text_direction' argument, 2: bloginfo() function name, 3: is_rtl() function name */ 
  77. __( 'The %1$s option is deprecated for the family of %2$s functions. Use the %3$s function instead.' ),  
  78. '<code>' . $show . '</code>',  
  79. '<code>bloginfo()</code>',  
  80. '<code>is_rtl()</code>' 
  81. ) ); 
  82. if ( function_exists( 'is_rtl' ) ) { 
  83. $output = is_rtl() ? 'rtl' : 'ltr'; 
  84. } else { 
  85. $output = 'ltr'; 
  86. break; 
  87. case 'name': 
  88. default: 
  89. $output = get_option('blogname'); 
  90. break; 
  91.  
  92. $url = true; 
  93. if (strpos($show, 'url') === false && 
  94. strpos($show, 'directory') === false && 
  95. strpos($show, 'home') === false) 
  96. $url = false; 
  97.  
  98. if ( 'display' == $filter ) { 
  99. if ( $url ) { 
  100. /** 
  101. * Filters the URL returned by get_bloginfo(). 
  102. * @since 2.0.5 
  103. * @param mixed $output The URL returned by bloginfo(). 
  104. * @param mixed $show Type of information requested. 
  105. */ 
  106. $output = apply_filters( 'bloginfo_url', $output, $show ); 
  107. } else { 
  108. /** 
  109. * Filters the site information returned by get_bloginfo(). 
  110. * @since 0.71 
  111. * @param mixed $output The requested non-URL site information. 
  112. * @param mixed $show Type of information requested. 
  113. */ 
  114. $output = apply_filters( 'bloginfo', $output, $show ); 
  115.  
  116. return $output; 
/wp-admin/includes/noop.php  
  1. function get_bloginfo() {}