Register Multiple Default Header Image In WordPress

WordPress, as CMS, let’s you register default header image for your built in WordPress themes. However, will it also allow you to add multiple default header image support for your built in WordPress project too? Well it does and here we will learn about how to register multiple default header image in WordPress.

What is header image in WordPress?

Well if you have followed up our previous tutorials then, you may already know that the header image is the main image for your site, which can better brand out your site. You can also use it to link to your own site or if needed, to other site as required for your site need.

Header image in WordPress has many features builtin within it. As we have already described about how to add header image support in WordPress as well as default header image support too, now here we will discuss about how to add or register multiple default header image in WordPress, shall we?

How to add default header image in WordPress?

If you have follow up our previous article then, you may already know about how to add theme support for header image as well as assigning the default header image within the currently builtin WordPress theme, isn’t it? Well if you have not followed up then, you just need to add the below PHP code in the functions.php file of the theme in the after_setup_theme WordPress hook:

From the above code as in previous article, we have added the theme support for header image as well as registering the default header image for that theme too via the 'default-image' parameter. Also, if you do not want those default values to be overwritten for same to add the custom header theme support then, you can only use the code: add_theme_support( 'custom-header' ); for same.

Now, since you know about the basic on adding default header image support within your theme, now let’s move ahead and learn about how to register multiple default header image in WordPress, shall we?

How to register multiple default header image in WordPress?

Now, since you know on adding default header image as from our previous article or from above hence here we will continue on learning to register multiple default header image in WordPress. For this, WordPress has provided you with the function register_default_headers() from which you can add more default header images as needed. Hence lets move ahead and do the same as needed, shall we?

This function: register_default_headers only works out when you pass the default header image within the header image support. And inside this function, you will pass the default header image as an array as needed. Hence let’s move ahead ad paste the below PHP code in the functions.php file for your theme:

Here, in the above PHP code, you can see that we have added three multiple header image as choices, however, you can add those as needed for your builtin theme. For that, you need to modify the array provided below as needed:

In which, you need to modify the url, thumbnail_url and description as needed pointing to the required image file as well as required description for that image. After doing out those changes now, you can utilize different header image for the same theme built in for WordPress within your site. Now, let’s move ahead and see the outcome for same, shall we?

Output of how to register multiple default header image in WordPress?

Now, if you have done the same as mentioned above for your builtin WordPress theme too then, you can see the similar output for same in your site as below of ours:

You may also want to read:

  1. Creating Sticky Post In WordPress
  2. Integrate Bootstrap NavBar 4 Into WordPress Theme
  3. Display Author Bio Without The Use Of Plugin
  4. Setting Up Static Front Page And Blog Page In WordPress
  5. Disable WordPress Post Revision

Conclusion

If you have followed up the tutorial properly and now can register multiple default header image within your WordPress theme with ease then, we can say that you are now more familiar on this than before. However, if you are still confused on the same and want to know more about it then, do drop the comment below in the comment box and we will follow it up.

Post navigation

Bishal Napit

Bishal Napit is a WordPress theme developer from Tansen, Palpa, with a passion to learn more on WordPress.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.