Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Display a default image for custom-logo

When you display the custom logo you can check if is set, if not you display another image. You can achieve this with the following code featured in the documentation. I adapted it to suit your needs:

$custom_logo_id = get_theme_mod( 'custom_logo' );
$logo = wp_get_attachment_image_src( $custom_logo_id , 'full' );
if ( has_custom_logo() ) {
        echo '<img src="'. esc_url( $logo[0] ) .'">';
} else {
        echo '<img src="'. get_stylesheet_directory_uri() . '/images/header.png' .'">';
}

Related Posts:

  1. Add more then one site logo – custom-logo theme support
  2. Get Custom Logo Alt Text
  3. how to add custom logo to my template
  4. How to unpixelate logo?
  5. Change Site Logo or Menu Logo Per Page
  6. Multiple logo’s in wordpress menu
  7. WordPress Page Width Issue: Seeking Solutions
  8. How to: Easily Move a WordPress Install from Development to Production?
  9. Is there a flowchart for WordPress loading sequence?
  10. Essential technical features for high-end WordPress web hosting? [closed]
  11. How to remove admin menu pages inserted by plugins?
  12. How to put logs in WordPress
  13. How to get the Date Format and Time Format settings for use in my template?
  14. Where are Additional CSS files stored
  15. Best Practices for Regression Testing WordPress Websites?
  16. Remove wrapping div and ul from output of wp_nav_menu
  17. What Is The Use Of map_meta_cap Filter?
  18. get post author id outside loop
  19. Custom Walker: how to get ID in function start_lvl
  20. Creative uses of WordPress [closed]
  21. How to *remove* a parent theme page template from a child theme?
  22. How do I make my child theme re-apply the settings that were customised when its parent was active?
  23. Multiple Inputs in a Customizer Control
  24. New WP_Customize API – how does it work under the hood?
  25. Embedding a SOAP Client into a WordPress Plugin?
  26. Is there anything that Joomla or Drupal can do that can’t be done in WordPress? [closed]
  27. Update widget form after drag-and-drop (WP save bug)
  28. Data sanitization: Best Practices with code examples
  29. How to benchmark a WordPress installation? [closed]
  30. Should I delete the default themes?
  31. Moving WP install from local to live, what about wp_posts GUID?
  32. Modified wp.media.view.Settings.Gallery in Backbone JS, but editing doesn’t work
  33. Running Gutenberg React in Development Mode
  34. Prevent WordPress from automatically installing a new theme each year
  35. Can we use one WordPress installation for multiple databases, domains and content directories
  36. Is there a blank theme framework compatible with WP 3.0? [closed]
  37. Plugin SVN & update API – how are plugins identified?
  38. Users with custom roles not showing in post author select box
  39. How to use more than 256MB of memory in the admin?
  40. How do register_sidebar() and get_sidebar() work together?
  41. How do you get formatted content of a post using the WordPress API?
  42. Localization: I want the backend: english and frontend in defined language
  43. Are there any forks of WordPress (and what is different about them)?
  44. How to Change 404 page title
  45. Make Custom Metaboxes Collapse by Default
  46. WordPress Paginate $wpdb->get_results
  47. Custom maintenance page
  48. Add button to TinyMCE bar without creating a plugin
  49. Why do I get the timeout warning?
  50. How to add a new product type on woocommerce product types? [closed]
  51. How to include own css on wordpress tinymce editor?
  52. How to disable page delete
  53. add button to post edit page when post_status=publish
  54. how to override woocommerce specific loop or archive-product.php [closed]
  55. Modify existing plugin function using filter (without modifying the plugin directly)
  56. Rename UPLOADS folder with custom WP_CONTENT_DIR
  57. WordPress hook before inserting post into database
  58. Any post install tips after installing WordPress 3.0.1?
  59. Making Custom Fields Standard in the Admin UI
  60. Remove WordPress theme from a specific page
  61. Version Control: Entire site or just pieces?
  62. Getting a stack trace when an error occurs?
  63. Check for and enforce unique value in user-entered custom meta field in WP Admin
  64. Backup the Database and Restore from the Backup?
  65. get_pages() not ordering as it should
  66. Scaling a WP eCommerce site
  67. Custom Search Query
  68. How to remove comment section from page only , not from posts pages?
  69. Looking for a lightweight theme using WP3 new tags and features (not 2010) [closed]
  70. Why doesn’t WP_Image_Editor save images using the Filesystem API?
  71. Pitfalls when Distributing Plugins that Access SOAP Web Services?
  72. How to get current_cat in navbar, in single post
  73. Default value for add_settings_field
  74. Seamless integration between WordPress and BBpress
  75. WordPress 3 MU for a development/stage/production site
  76. Disable Visible Edit Shortcuts in the Customizer
  77. How to make a script load after Custom Block is loaded in the editor?
  78. Updating WordPress overwriting customization tweaks – strategies?
  79. What is the best way to customise admin files so they survive future upgrades?
  80. Hide admin notices/notifications from everyone but super admin?
  81. Change the login button on the login page
  82. How to customize the default HTML for WordPress Attachments
  83. Verify nonce in REST API?
  84. Add custom html to last sub-menu item
  85. Get all products with a custom attribute
  86. Customizing the Subject Field in WordPress’ Notification Emails?
  87. How to update the delete user confirmation form?
  88. How to move wp-content (or uploads) outside of the WordPress directory
  89. Need help with friendly URL’s in WordPress
  90. How to add Disqus comment count
  91. How to keep a WordPress site synchronized between two servers?
  92. Upgrading WordPress and Plugins; any Tips to Avoid Trouble?
  93. Modify column_author in WP_Comments_List_Table
  94. Why do folders have Empty Index.php Pages?
  95. How to Add Customizer Setting in Child Theme
  96. When adding a custom REST endpoint, where do you put the endpoint function, and where do you put the function registration call?
  97. Multiple WordPress sites with docker
  98. .maintenance and maintenance.php also in multisite install?
  99. Limit Media Library to Given Folder
  100. Is it possible to use Gutenberg on the front-end?
Categories customization Tags customization, genesis-theme-framework, logo
Confused on AJAX submit form through page template
What does this message from WP_DEBUG mean?

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress