I have a custom logo and I have tried to get his path in this way theme_get_setting('logo_path'), but no expected result.

I am using the code in a custom block, in input PHP.

  • 3
    Where are you using this code? Have you tried theme_get_setting('logo_path', 'THEME_NAME'), replacing THEME_NAME with the name of your theme? Mar 21, 2011 at 13:21

2 Answers 2


logo_path seems to only be set if you override the theme's default logo via its theme settings. To get the default logo, use theme_get_setting('logo').

  • But why the result of theme_get_setting('logo') is empty string ? I have set my custom logo in /admin/appearance/setting
    – EKK
    Mar 21, 2011 at 13:53
  • Why when Logo is deactivate from theme TOGGLE DISPLAY - Enable or disable the display of certain page elements. the theme_get_setting('logo') has no results. Why ?
    – EKK
    Mar 21, 2011 at 14:28
  • 1
    Thanks, that's exactly what I was looking for! Use <a href="<?php echo theme_get_setting('logo');?>"> in a PHP code block to show the logo in your own block.
    – Coomie
    Dec 2, 2014 at 8:39
global $base_url;

if (!$logo = theme_get_setting('logo_path')) {
    $logo = theme_get_setting('logo');

if (!empty($logo)) {
  // [1]
  // Remove the base URL from the result returned by theme_get_setting('logo').
  // If you don't need the relative path, you can remove this code.
  if (strpos($logo, $base_url) === 0) {
    $logo = drupal_substr($logo, drupal_strlen($base_url));
  // [1]
  // …

The call to drupal_theme_initialize() is not strictly necessary, and it doesn't do anything if the global variable $theme is already initialized.
The code is removing the base URL because the value reported from theme_get_setting('logo') is an absolute path; if you don't need a relative path to access the file, then the part between // [1] can be removed.

When the logo has been disabled in the theme settings, theme_get_setting('logo') doesn't return anything.

  • 1
    I replaced the code in [1] with $logo = file_create_url($logo); in order to get the full URL path of the logo (with the http://). Aug 5, 2014 at 10:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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