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:
- How to add CSS class to custom logo?
- How to insert a logo in the header?
- How to remove the Theme Customization Button from the dashboard and themes options page?
- What filters are applied to the_content function?
- Change admin bar to default:off
- How to modify an image block in Gutenberg WordPress 5?
- Edit srcset and sizes attributes in Gutenberg image, cover and gallery – blocks
- wp_get_attachment_image_attributes not working for me
- How to change get_custom_logo() url?
- Display a different theme for not logged-in users
- Run shortcode before filters
- Add class to before_widget for all widgets with a dropdown and a counter
- How to Auto Approve Comments on a Specific Page?
- What flex-width/height does?
- Get password when user registers and save it sha1 into database
- Passing variable in hooks and filter
- WordPress nav_menu_css_class theme filter is not being called
- customizing the_password_form filter
- WordPress Genesis Child Theme Filter divs
- Change file name from wp_generate_attachment_metadata
- No Appearance –> Header menu
- Simple way to get two language WP site
- Highlight “Show all” item in wp_list_categories
- WordPress navbar with logo in middle [closed]
- When trying to override plugin’s function by theme, my filter executes two times, I want it to run only a single time
- Menu item added in wp_nav_menu_items filter is never highlighted
- Should I use add_filter for functions in function.php of the theme?
- Pass variable to hook. Its possible?
- WordPress taxonomy and archive custom class
- Filter categories used with Custom Structure Permalink
- How to wrap all titles generated by Gutenberg “Heading” block with tag
- Replace single_template filter with what for default posts?
- Unique design inside a specific category’s url
- How to rotate every letter in a title
- How to disable thumbnail filter for a specific template part or image size?
- CSS class on last post in loop ( custom query )
- How to change footer credit text in Twenty Twenty One theme with a hook?
- Use a filter on menu items that have children
- Modify available templates (in dropdown)
- tiny_mce_before_init: ‘exact’ => true has no effect
- How to conditionally add a wp_filter
- Filter didn’t work on content class (hybrid_post_attributes)
- How to set default values for edit_post_link() in my theme?
- Tiny MCE custom styles, and preview in the backend
- content filter (add_filter) for category description?
- Related Post Category Filter
- Pagination don’t work with active filters
- How to register dynamic settings in WordPress Customizer?
- restrain filter on get_the_excerpt to queried item in stead of current post
- SIte logo is not displaying
- Adding a second logo next to the main one in header
- WordPress wp_get_current_user returning blank values until refresh
- Alternative solution for script_loader_tag?
- WordPress Twenty-Fourteen: How to Remove Home Page Header Image from Other Pages
- Make a custom field in admin post.php read only
- Hook in parent theme Menu function
- How do I remove p tag *insertions*? Disabling `wpautop` removes manual tags
- How to add custom nav_menu_css_class to certain menu only?
- How to manipulate wordpress template tags’ output
- what is do_action(); in wordpress? [duplicate]
- Suppress the_content filter in a nested loop
- apply_filters to featured image
- Add rel to all images in a post
- Is there any filter or action hook to remove layout classes from appearing in my templates?
- Only show read more text when when wp:post-excerpt meets excerptLength
- WP “optimizing” PNGs into thumbnails 5X larger than originals – FIX
- optimized PNGs 5X larger than originals
- Menu items description? Custom Walker for wp_nav_menu()
- How to define and link full path to css located at a random folder on header.php
- Sizing screenshot.png without losing aspect ratio
- Software for WordPress Theme and Plugin Development? [closed]
- When to use is_home() vs is_front_page()?
- What is the preferred way to add custom javascript files to the site?
- Get the blog page URL set in Options
- How to create .pot files with POedit?
- How do I get the theme URL in PHP?
- Why when I submit a form in wordpress it loads a 404 page though URL is correct
- What is the constant WP_USE_THEMES for?
- Worthwhile to restrict direct access of theme files?
- How Do I Protect My Premium WordPress App Theme from Copying?
- How to detect mobile devices and present them a specific theme?
- Using wp_add_inline_style without a stylesheet
- How to add posts to custom menus?
- WordPress Theme Preview Image
- How To extend WP_Customize_Control
- What is the difference between front-page.php and home.php? [duplicate]
- How can I get page slug
- Does the functions.php file ever get called during an AJAX call? Debug AJAX
- When to use _e and __ for the translation?
- What is a Theme textdomain?
- How to show a custom meta box on the “Quick Edit” screen?
- How to add custom css file in theme?
- How important is it to enqueue a theme’s stylesheet?
- CSS not updating in browser when I change it
- Display Search Result Count
- wp_nav_menu(), how to change class?
- theme path in javascript file
- Is wp_is_mobile() effective?
- Display Menu Name using wp_nav_menu
- Making update notification functionality for my themes