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

Alt header logo and link for specific pages

You are not using all possibilities of the get_custom_logo filter. As you can see from the source not only the $html is passed to it, but also the $blog_id. You can use the latter to do a preg_replace on the link like this:

add_filter ('get_custom_logo','wpse305624_change_logo_link',10,2);
function wpse305624_change_logo_link ($html,$blog_id) {
  $homelink = get_home_url ();
  $bloglink = get_permalink ($blog_id); // or anything else, for instance the blogs's parent
  $html = preg_replace ($homelink,$bloglink,$html);
  return $html;
  }

By the way, you could also use the filter on get_theme_mod (called at the beginning of get_custom_logo) to modify the returned image id in the first place, so you don’t have to do a preg_replace afterwards. Unfortunately I don’t see a similarly elegant way to manipulate the url.

Related Posts:

  1. How to add CSS class to custom logo?
  2. How to insert a logo in the header?
  3. How to remove the Theme Customization Button from the dashboard and themes options page?
  4. What filters are applied to the_content function?
  5. Change admin bar to default:off
  6. How to modify an image block in Gutenberg WordPress 5?
  7. Edit srcset and sizes attributes in Gutenberg image, cover and gallery – blocks
  8. wp_get_attachment_image_attributes not working for me
  9. How to change get_custom_logo() url?
  10. Display a different theme for not logged-in users
  11. Run shortcode before filters
  12. Add class to before_widget for all widgets with a dropdown and a counter
  13. How to Auto Approve Comments on a Specific Page?
  14. What flex-width/height does?
  15. Get password when user registers and save it sha1 into database
  16. Passing variable in hooks and filter
  17. WordPress nav_menu_css_class theme filter is not being called
  18. customizing the_password_form filter
  19. WordPress Genesis Child Theme Filter divs
  20. Change file name from wp_generate_attachment_metadata
  21. No Appearance –> Header menu
  22. Simple way to get two language WP site
  23. Highlight “Show all” item in wp_list_categories
  24. WordPress navbar with logo in middle [closed]
  25. When trying to override plugin’s function by theme, my filter executes two times, I want it to run only a single time
  26. Menu item added in wp_nav_menu_items filter is never highlighted
  27. Should I use add_filter for functions in function.php of the theme?
  28. Pass variable to hook. Its possible?
  29. WordPress taxonomy and archive custom class
  30. Filter categories used with Custom Structure Permalink
  31. How to wrap all titles generated by Gutenberg “Heading” block with tag
  32. Replace single_template filter with what for default posts?
  33. Unique design inside a specific category’s url
  34. How to rotate every letter in a title
  35. How to disable thumbnail filter for a specific template part or image size?
  36. CSS class on last post in loop ( custom query )
  37. How to change footer credit text in Twenty Twenty One theme with a hook?
  38. Use a filter on menu items that have children
  39. Modify available templates (in dropdown)
  40. tiny_mce_before_init: ‘exact’ => true has no effect
  41. How to conditionally add a wp_filter
  42. Filter didn’t work on content class (hybrid_post_attributes)
  43. How to set default values for edit_post_link() in my theme?
  44. Tiny MCE custom styles, and preview in the backend
  45. content filter (add_filter) for category description?
  46. Related Post Category Filter
  47. Pagination don’t work with active filters
  48. How to register dynamic settings in WordPress Customizer?
  49. restrain filter on get_the_excerpt to queried item in stead of current post
  50. SIte logo is not displaying
  51. Adding a second logo next to the main one in header
  52. WordPress wp_get_current_user returning blank values until refresh
  53. Alternative solution for script_loader_tag?
  54. WordPress Twenty-Fourteen: How to Remove Home Page Header Image from Other Pages
  55. Make a custom field in admin post.php read only
  56. Hook in parent theme Menu function
  57. How do I remove p tag *insertions*? Disabling `wpautop` removes manual tags
  58. How to add custom nav_menu_css_class to certain menu only?
  59. How to manipulate wordpress template tags’ output
  60. what is do_action(); in wordpress? [duplicate]
  61. Suppress the_content filter in a nested loop
  62. apply_filters to featured image
  63. Add rel to all images in a post
  64. Is there any filter or action hook to remove layout classes from appearing in my templates?
  65. Only show read more text when when wp:post-excerpt meets excerptLength
  66. WP “optimizing” PNGs into thumbnails 5X larger than originals – FIX
  67. optimized PNGs 5X larger than originals
  68. Menu items description? Custom Walker for wp_nav_menu()
  69. How to define and link full path to css located at a random folder on header.php
  70. Sizing screenshot.png without losing aspect ratio
  71. Software for WordPress Theme and Plugin Development? [closed]
  72. When to use is_home() vs is_front_page()?
  73. What is the preferred way to add custom javascript files to the site?
  74. Get the blog page URL set in Options
  75. How to create .pot files with POedit?
  76. How do I get the theme URL in PHP?
  77. Why when I submit a form in wordpress it loads a 404 page though URL is correct
  78. What is the constant WP_USE_THEMES for?
  79. Worthwhile to restrict direct access of theme files?
  80. How Do I Protect My Premium WordPress App Theme from Copying?
  81. How to detect mobile devices and present them a specific theme?
  82. Using wp_add_inline_style without a stylesheet
  83. How to add posts to custom menus?
  84. WordPress Theme Preview Image
  85. How To extend WP_Customize_Control
  86. What is the difference between front-page.php and home.php? [duplicate]
  87. How can I get page slug
  88. Does the functions.php file ever get called during an AJAX call? Debug AJAX
  89. When to use _e and __ for the translation?
  90. What is a Theme textdomain?
  91. How to show a custom meta box on the “Quick Edit” screen?
  92. How to add custom css file in theme?
  93. How important is it to enqueue a theme’s stylesheet?
  94. CSS not updating in browser when I change it
  95. Display Search Result Count
  96. wp_nav_menu(), how to change class?
  97. theme path in javascript file
  98. Is wp_is_mobile() effective?
  99. Display Menu Name using wp_nav_menu
  100. Making update notification functionality for my themes
Categories theme-development Tags filters, logo, theme-development
How to add custom option to wp_dropdown_categories?
Why is my custom WordPress Customizer section disappearing after about a second?

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