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. Display random categories on the front page (Finding and Editing Theme Functions)
  4. How to get woocommerce inventory status [closed]
  5. TinyMCE custom styles remove class when switching styles
  6. How to use get_template_directory_uri() to load an image that is in a sub-folder of my theme?
  7. Show/hide Widgets in Dashboard Based on Current Advanced Custom Fields Option
  8. Return only top-level navigation items from a menu using wp_get_nav_menu_items
  9. Organize functions.php
  10. How to override functions.php in child theme?
  11. Overriding core functions in child theme
  12. Change parent theme file function in child themes functions.php
  13. Add inline css to theme
  14. Dequeue Scripts and Style for Mobile not working?
  15. Displaying Widgets
  16. Dequeue script in template isn’t working
  17. Add external js file to footer with id
  18. Custom logo sizes for multiple logos
  19. How to add background image control to page admin controls?
  20. Best Practice for Syncing Local Development With Staging Development [closed]
  21. Overwrite Parent Theme add_image_size in Child Theme
  22. Show excerpt for only first post in query
  23. Custom Logo URL | Help me print the URL of the custom logo I inserted into my theme
  24. How to add css class to image attached in all the posts?
  25. How to call custom function from functions.php in site-wide template files?
  26. How to use thumbnails in gallery?
  27. Logic to Print/echo a css class only for 1st post and ignore all post after 1st? [closed]
  28. Is there a way to add a class to non current menu item?
  29. When using wp_enqueue_script(); in a theme why don’t we use add_action?
  30. How to use Internationalized human_time_diff() function in Chinese?
  31. is_dynamic_sidebar always returns true while using Jetpack visibility
  32. How to enable template page only for a post id page
  33. Why does the ‘wp_nav_menu’ function work only until a menu is created?
  34. Add caption functionality to custom WordPress theme
  35. is_customize_preview() like function to check if Customizer “Live Preview” in JavaScript
  36. Override a theme function in a child theme?
  37. Pulling Twitter RSS feed not working as expected (fatal error)
  38. Use register_setting() in a loop
  39. Best practices regarding the creation of custom widgets?
  40. Add dynamic links in WordPress custom theme
  41. WordPress menu link doesn’t work properly
  42. Search filter by Post title OR Meta Title Value [duplicate]
  43. how can I edit flexslider in woocommerce. [Urgent]
  44. admin-ajax.php + load-scripts.php hanging for minutes
  45. enqueue styles for only mobile wp
  46. Jquery implementation not working on page reload
  47. Unique sequential reservation code
  48. Getting the teaser text without overriding global variables
  49. Combine two active_callbacks into one on theme customizer
  50. WP Customizer API loaded into functions.php
  51. call_user_func_array() expects parameter 1 to be a valid callback, function
  52. why can’t i add front.css to my frontpage.php
  53. “options.php” not found
  54. How to store a number (coming from cookie) into query vars for later usage in other filters?
  55. Is this an acceptable practice for WordPress theme development?
  56. What is the correct way to include my new functions and scripts in WordPress?
  57. wp_nav_menu work in functions.php but not in the theme
  58. Rewrite Question Mark in Post Template with URL Parameter for clean URLs
  59. contact form in template with jquery,validate and ajax
  60. 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]
  61. Why I can’t load my JavaScripts using an hook inside my functions.php file?
  62. Woocommerce Variable Product Dropdown for Custom Shop Template
  63. How to fix Function create_function() is deprecated in / themes
  64. Exclude specific post from query
  65. Advanced method to control cache of enqueued style/script
  66. WordPress wp_dequeue_script remove all other scripts
  67. Can I use ‘Featured Image’ as a hero image and a thumbnail?
  68. Is_Page doesnt detect my page
  69. Test CDN link from function.php or wp_enqueue_script/style?
  70. How to customize archive widget only for cpt?
  71. wp_title() return random number
  72. Why does echo on functions.php not yield result in source code?
  73. How to offset main query without affecting other queries and backend
  74. Add meta data in head from theme
  75. what is `get_section()` and how to use it?
  76. Remove External Links from WordPress posts Using add_filter() in Theme functions.php
  77. How to retrieve image IDs from shortcode content?
  78. HowTo: Add wrapper to columns shortcode?
  79. How to create admin ajax function for my contact form
  80. Help! Need a different logo on my main page from my other pages
  81. Class::$template_dir_path=get_template_directory();
  82. How to disable site title and description when custom header is uploaded on the customizer?
  83. wordpress not calling peliegro functions.php?
  84. Language switcher for subdomains
  85. How to add next height number in Order Attributes inside the Add new page. [duplicate]
  86. Load a Child Theme’s style.css just before the closing tag
  87. wp_nav_walker that interacts with widgets to setup mega menu
  88. Allow tags and attributes in post and pages content
  89. Add the title of a widget as an ID – for anchor links
  90. Add custom css to theme
  91. Why functions metaboxes is causing White Screen in Admin [closed]
  92. Getting error on function.php
  93. Why don’t ‘wp_nav_menu’ CSS classes work until a menu is created?
  94. How to get postId from the argument $block when register_block_type()?
  95. WordPress is adding pagination for all pages not only for blog page, How to remove pagination for all pages except blog/posts page?
  96. Setcookie not setting cookies anywhere except admin
  97. 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
  98. How can I able to exclude ‘Category’ and ‘Tag’ slug from the URL in WordPress without reloading to new site?
  99. No src and sizes attributes present on WordPress thumbnail images; the smallest image size is loaded irregardless of viewport size
  100. add_image_size() parameter four ($crop = true) is ignored: the_post_thumbnail() returns scaled image(s) instead of hard cropped
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
  • Post Navigation Elementor
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • WPFacet multiple loop displaying duplicate content
  • Get the name of the template/*html file used
  • Fix: WordPress.DB.PreparedSQL.NotPrepared Plugin Check (PCP)
  • Removing unnecessary CSS and JS code from wp_head()
  • hexagonal image gallery. Am I on the right track? [closed]
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
© 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