The examples you’ve seen are out of date. From WordPress 4.5, released in 2016, the proper way to support a custom logo was to register support for the Custom Logo feature in your theme.
That link has the full documentation, but the short version is that you use this code to enable the standard logo field in the Customiser:
add_theme_support( 'custom-logo' );
Then you can output the selected logo in the theme with:
the_custom_logo();
In the modern Block themes no code is necessary; the user can add their logo by using the Site Logo block.
Related Posts:
- How wordpress handle upload images and how to use them in the code
- WordPress Media Uploader in page template (On Front-end)
- Can I get the ID of an inserted / linked image?
- Changing Header Image Every N Minutes/Seconds
- Theme logo metadata into template file
- WordPress creating images if uploaded image is greater than 960px on one side?
- How to add cropped custom header image?
- Can’t upload images on new theme
- WordPress Theme Preview Image
- The the_post_thumbnail without srcset?
- Get the first image from post content (eg.: hotlinked images)
- How to modify an image block in Gutenberg WordPress 5?
- Edit srcset and sizes attributes in Gutenberg image, cover and gallery – blocks
- Can I create customizer setting that can handle plugin shortcode?
- wp_get_attachment_image_attributes not working for me
- Specify image dimensions
- How to force Media manager to overwrite files of same name?
- How to get gallery images?
- Featured Image in 4.4 should be larger on mobile device
- How to use the responsive images feature from WP 4.4 in your themes
- Confused about image sizing business in WordPress
- Unexpected width and srcset attributes for the_post_thumbnail();
- How do I get gallery thumbnail URL and change the default thumbnail size?
- How can I stop WP media uploader from creating duplicates of my uploaded images?
- Responsive class to all the images in the content
- Featured Image Size
- Get attachments by user
- How to set dimensions of the post thumbnails (featured images)
- How to regenerate thumbnails when they’re stored on S3
- Cannot get full thumbnail size using the_post_thumbnail
- How can one update a theme on a live site without interruption?
- Adding wp_enqueue_media(); causes problem
- How to upload images using Settings API
- wp_get_attachment_image_src() width and height boolean
- How to float an image in Gutenberg
- Media Uploader in custom path
- Custom Field returning Numerical Value for Image rather than URL
- Why an arugment is missing in wp_get_attachment_image_attributes?
- Reasons why all thumbnail sizes aren’t working
- How to make a local cache of mshots images
- Customizer: Unique identifier that distinguishes which image upload control is uploading an image
- How do I Add images uploaded in the post to a default custom field
- attachment.php code or tutorial
- Change “Thumbnail”, “Medium” and “Large” image sizes using functions.php?
- image url relative path not working in css file
- Unable to check if image uploaded by wp_image_editor exists using file_exists function
- Default image size not working
- How can i attach the attachment-ID to the user profile image?
- How do I include pre-installed images in a theme?
- Add attachment for all images in post
- Do not display post images on front page
- What is the meaning of WordPress’s recommended css classes and where are they applied?
- Gallery thumbnails very small
- Custom image size vs CSS sizing
- Getting Different Size Of Attachment Images
- Can I add an icon & function to the “Upload/Insert” toolbar at the top of the content editor?
- In creating a theme, how can i allow a user to change an image outside post/page content?
- Change Responsive Images Maximum Width of 1600px
- Set a featured image as a replacement to the header image
- How to show a manageable list of images on a post?
- Change image size depending on page
- How to disable thumbnail filter for a specific template part or image size?
- Theme Customizer not displaying saved values in wp_head (CSS)
- How to obfuscate theme directory URLs
- Are seven additional image sizes are too many?
- Remove link on full-size images
- How do I provide for multiple crops of the same image in a theme?
- how to retrieve the image title for image Post Format
- How to fix WordPress images not showing up in local hosted XAMPP server?
- Change Image Sizes for Mobile Theme
- HTTP Error when uploading images over specific dimensions
- Stop WordPress from showing images on non post pages
- How to make excerpt image be full size instead of thumbnail?
- Is there a way to serve different resolution images to different devices?
- How can I scale down the width of images in bulk that are embedded in posts throughout the site?
- Add image URL automatically to custom field?
- How can I remove image taxonomy pages from my theme and from Google?
- Dynamic Image Links Depending on Excerpt/’Single Post’ View
- Designing a custom archive.php inspired by the Autofocus theme
- ACF get_sub_field ALT TAG in the repeater doesn’t show
- WordPress Animation Adjustments
- theme directory fallback image outputs url and not the image
- Post Featured Image Custom Sizing?
- Image cropping isn’t working correctly when using Offload Media
- How to add an image to a theme page template in code?
- How do I remove header/page-title image in farvis theme? [closed]
- Responsive Images with art direction
- WordPress uploads do not show up and I see the white screen of death in some cases
- Customizer Image-Picker Preview Not Working
- Correct was to customise theme using get_theme_mod in scripts
- Change header image on a particular page
- Uncaught Reference error in Retina.js
- Images use & location, on new wordpress theme
- Save the outputted image into the Media Library, with a different filename and extension
- Create image with imagepng() (fails at header)
- Custom image size doesn’t work
- Retina ready for uploaded images which are cropped
- Add rel to all images in a post
- Isotope overlapping .items because of featured images – HELP! [closed]
- I want to resize post featured image without cropping image. How?