How to Change the Default WordPress Website Link Image

Have you ever noticed that when you’re on a website, there’s usually a small image of a person or a building that you can click on to get to the site’s home page?

Whether an image tag with an href pointing to the site’s home or a simple background image, that small graphic is the standard way websites connect users to content.

It would be great if there was a way to change that default graphic programmatically so you can easily replicate it on any website you build.

Fortunately, there is a way you can do this using a simple WordPress filter.

We’ll walk you through the process of how to change the default WordPress website link image so you can understand the steps necessary to replicate this on your own site.

Step 1: Find Out Where the Image Is Stored

The first step is to find out where the images for your site are stored. You can do this by navigating to the WordPress dashboard and going to Settings > Settings->Media gallery. From here, you can navigate to the folder where your images are located and drag them into a new window so you can see the complete upload list.

As you can see, there are a variety of images stored at our site. When we first installed WordPress, the images were stored in the /wp-content/uploads/ folder which is why you’ll often see a small thumbnail and an href=”” pointing to the /wp-content/uploads/ folder when you’re on a WordPress website.

Now, let’s say we want to change the default image for our home page to a graphic of a mountain range.

We could go through and change each thumbnail on the site to this alternate image but that can get pretty tiresome. Instead, let’s use a filter to change the home page image for every WordPress site.

Step 2: Create a New Filename for the New Image

The second step in our process is to create a new filename for our new image. The ideal way to do this is to use the Generate Media Library Short Caption filename. This will create a new image with a random string of characters as a file name.

So, in our example, let’s say we named our new image’mountains-01.jpg’. Using our new filename, we can now upload our new image into the media library with this direct link: https://localhost:4436/wp-content/uploads/mountains-01.jpg.

Now, let’s say we want to change the graphic for our About page to one of a rocket ship hovering over a city.

This is a lot easier to do. We can use the Generate Media Library Short Caption filter to create a new image with a random string of characters as a file name but this time, let’s say we want to use the word ‘rocketeer’ in the filename. So, now, our new image has a proper filename and we can upload it into the media library with a direct link: https://localhost:4436/wp-content/uploads/rocketeer-01.jpg.

As you can see, with a simple filter and some random file naming, we can easily change the link to point to any image we want for our site.

This is a powerful tool because now we can change the link for any image on any WordPress site without having to go back and forth to the media library manually to update each one.

Step 3: Change The Href

The third step in our process is to change the href for our new image. Again, we could go back and forth between the media library and our WordPress dashboard to find the correct link address but that’s a lot of work. Luckily, there’s an easier way. If we’re in Settings -> Settings-> Media gallery, there’s a simple field called ‘Home page URL/Design’.

This is a dropdown menu where we can easily change the URL for our home page to point to our new image. So, in our example, we can either use or depending on what internet protocol we’re using.

Step 4: Test Out the New Link

The last step in our process is to test out the new link we just created. Let’s say we’re on our home page and we want to see how our new image looks. Simply navigate to Settings -> Settings-> Media gallery and click on the Preview button next to the image we just changed to point to our new image.

Now, we can either use

Ctrl + Left Arrow

or

Shift + Left Arrow

to navigate our browser to the previous page or click on the back button to return to the previous URL.

As you can see above, our new image displays perfectly on our home page. Now, let’s say we’re on one of our other pages and we want to see how our new link looks there. Once more, we can either use

Ctrl + Left Arrow

or

Shift + Left Arrow

to navigate our browser to the previous page or click on the back button to return to the previous URL.

As you can see above, the image doesn’t display correctly because we’re on a different page than the one our home page is attached to. In WordPress, we can use the is_page() function to determine if the current post is displaying on the homepage or a different page. If it’s on the homepage, the page will have an HTML heading with the id “header” and a navigation menu below it. The code for our home page looks like this:

As you can see above, our home page is an html page with the following basic structure: