Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How would I override a bloginfo variable in wordpress?

For example, I want to replace this:

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

to return a custom URL like http://mysites.com/hello/

share|improve this question
add comment

migrated from superuser.com May 29 '11 at 1:34

This question came from our site for computer enthusiasts and power users.

1 Answer

For the example you mentioned, you can add a filter to the stylesheet_directory hook

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 ;
 }

For any of the other parameters for bloginfo, you can look at the code for for bloginfo, which is in wp-includes/general-template.php. Follow the calls made for other bloginfo parameters to see whether there is a filter for it.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.