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

Changing itemprop from logo to image on custom logo?

I assume you have problem with google validator about itemprop="logo". You can hook into the get_custom_header filter and alter the HTML structure:

add_filter( 'get_custom_logo', 'my_custom_logo' );
// Filter the output of logo to fix Googles Error about itemprop logo
function my_custom_logo() {
    $custom_logo_id = get_theme_mod( 'custom_logo' );
    $html = sprintf( '<a href="https://wordpress.stackexchange.com/questions/269388/%1$s" class="custom-logo-link" rel="home" itemprop="url">%2$s</a>',
            esc_url( home_url( "https://wordpress.stackexchange.com/" ) ),
            wp_get_attachment_image( $custom_logo_id, 'full', false, array(
                'class'    => 'custom-logo',
            ) )
        );
    return $html;   
}

Add the above code to your theme’s functions.php or follow the steps here to create a child theme and use this code in it’s functions.php file.

Edit

Based on @birgire’s comment, i wrote another function to filter the wp_get_attachment_image():

add_filter('wp_get_attachment_image', function ($attachment_id, $size , $icon , $attr) {
        // If the class is 'custom-logo', then change the itemprop to image
        if ($attr['class'] =='custom-logo') {
            $attr['itemprop'] = 'image';
        }
        return $attr;
},10,3);

Related Posts:

  1. Issues with title-tag and document_title_parts
  2. Is it ok to use a function to output the text domain name in a wordpress theme
  3. How to get woocommerce inventory status [closed]
  4. TinyMCE custom styles remove class when switching styles
  5. Show/hide Widgets in Dashboard Based on Current Advanced Custom Fields Option
  6. Organize functions.php
  7. Overriding core functions in child theme
  8. Change parent theme file function in child themes functions.php
  9. Dequeue Scripts and Style for Mobile not working?
  10. Displaying Widgets
  11. Dequeue script in template isn’t working
  12. Custom logo sizes for multiple logos
  13. Best Practice for Syncing Local Development With Staging Development [closed]
  14. Overwrite Parent Theme add_image_size in Child Theme
  15. Show excerpt for only first post in query
  16. Custom Logo URL | Help me print the URL of the custom logo I inserted into my theme
  17. How to add css class to image attached in all the posts?
  18. How to call custom function from functions.php in site-wide template files?
  19. Logic to Print/echo a css class only for 1st post and ignore all post after 1st? [closed]
  20. Is there a way to add a class to non current menu item?
  21. When using wp_enqueue_script(); in a theme why don’t we use add_action?
  22. How to use Internationalized human_time_diff() function in Chinese?
  23. is_dynamic_sidebar always returns true while using Jetpack visibility
  24. How to enable template page only for a post id page
  25. Why does the ‘wp_nav_menu’ function work only until a menu is created?
  26. Add caption functionality to custom WordPress theme
  27. is_customize_preview() like function to check if Customizer “Live Preview” in JavaScript
  28. Override a theme function in a child theme?
  29. Pulling Twitter RSS feed not working as expected (fatal error)
  30. Use register_setting() in a loop
  31. Best practices regarding the creation of custom widgets?
  32. Add dynamic links in WordPress custom theme
  33. WordPress menu link doesn’t work properly
  34. Search filter by Post title OR Meta Title Value [duplicate]
  35. admin-ajax.php + load-scripts.php hanging for minutes
  36. enqueue styles for only mobile wp
  37. Jquery implementation not working on page reload
  38. Unique sequential reservation code
  39. Functions.php Problem
  40. ACF not showing
  41. How to customize the_archive_title()? Cannot figure out how to change the value it produces [duplicate]
  42. Control the srcset much more (not all sizes in it each time)
  43. Way to store featured image width and height in two separate variables?
  44. Remove Custuomize Sections
  45. Excerpt for pages not showing
  46. get_pages() Returns Only One Item
  47. Some questions about how proper add 2 CSS file in a WordPress theme?
  48. Does size of a theme’s functions.php file matter?
  49. Functions php shortcode for displaying main menu with no child items
  50. get_next_posts_link() returns no result despite available posts
  51. Nav menus all outputting the same links
  52. PHP 7.1 | Warning: A non-numeric value encountered in
  53. How to properly set custom logo size?
  54. How to insert class in each list of categories?
  55. Convert multiple logos into the_custom_logo
  56. I can’t add CSS with functions.php
  57. How can I set the SRC URL of the custom logo image?
  58. Getting the teaser text without overriding global variables
  59. Combine two active_callbacks into one on theme customizer
  60. WP Customizer API loaded into functions.php
  61. call_user_func_array() expects parameter 1 to be a valid callback, function
  62. why can’t i add front.css to my frontpage.php
  63. “options.php” not found
  64. Is this an acceptable practice for WordPress theme development?
  65. Rewrite Question Mark in Post Template with URL Parameter for clean URLs
  66. contact form in template with jquery,validate and ajax
  67. Why a SlideShow (made using JQuery FlexSlider) can’t work if I load it form functions.php but work if I load it from my footer.php file? [closed]
  68. Why I can’t load my JavaScripts using an hook inside my functions.php file?
  69. Woocommerce Variable Product Dropdown for Custom Shop Template
  70. How to fix Function create_function() is deprecated in / themes
  71. Exclude specific post from query
  72. Advanced method to control cache of enqueued style/script
  73. Can I use ‘Featured Image’ as a hero image and a thumbnail?
  74. Is_Page doesnt detect my page
  75. Test CDN link from function.php or wp_enqueue_script/style?
  76. How to customize archive widget only for cpt?
  77. wp_title() return random number
  78. Why does echo on functions.php not yield result in source code?
  79. How to offset main query without affecting other queries and backend
  80. Add meta data in head from theme
  81. what is `get_section()` and how to use it?
  82. Remove External Links from WordPress posts Using add_filter() in Theme functions.php
  83. How to retrieve image IDs from shortcode content?
  84. HowTo: Add wrapper to columns shortcode?
  85. How to create admin ajax function for my contact form
  86. Help! Need a different logo on my main page from my other pages
  87. Class::$template_dir_path=get_template_directory();
  88. How to disable site title and description when custom header is uploaded on the customizer?
  89. Language switcher for subdomains
  90. Load a Child Theme’s style.css just before the closing tag
  91. wp_nav_walker that interacts with widgets to setup mega menu
  92. Allow tags and attributes in post and pages content
  93. Add the title of a widget as an ID – for anchor links
  94. Add custom css to theme
  95. Why functions metaboxes is causing White Screen in Admin [closed]
  96. Getting error on function.php
  97. Why don’t ‘wp_nav_menu’ CSS classes work until a menu is created?
  98. How to use webpack in WordPress theme? I want some scripts to load in the footer, some in the header and some with script parameters
  99. How can I able to exclude ‘Category’ and ‘Tag’ slug from the URL in WordPress without reloading to new site?
  100. No src and sizes attributes present on WordPress thumbnail images; the smallest image size is loaded irregardless of viewport size
Categories functions Tags functions, logo, theme-development
How do I add a javascript file to all admin pages via a plugin?
Rest API Custom Endpoint with space character

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