Add custom background in WordPress theme

Custom background is a WordPress feature that allows you to customize background color/image from backend. Custom background gives your blog to a nice look. You can add default color and image. For enable custom background you have to use this function in your function.php file within themeslug_setup() function.

add_theme_support( 'custom-background' );

After using this you can see the background menu option under appearance menu. Make sure you theme header file have body_class() inside body tag and wp_head(); within the head tag like this:

<body <?php body_class(); ?>>

So whenever you can add background color or image this function can generate a style within head tag and it will override your theme stylesheet. Now let me show you some functions which allows you set up default color and image.



Here is the full code:

$custom_bg = array(
	'default-color'          => '',
	'default-image'          => '',
	'default-repeat'         => '',
	'default-position-x'     => '',
	'default-attachment'     => '',
	'wp-head-callback'       => '_custom_background_cb',
	'admin-head-callback'    => '',
	'admin-preview-callback' => ''
);
add_theme_support( 'custom-background', $custom_bg);

Hope you like this article. We welcomes your question and comments.
Thanks for reading.

83 thoughts on “Add custom background in WordPress theme”

  1. hello ..

    Any chance you could explain how to add a background for a page rather than a post?
    Am hoping to add individual images for various pages with opacity set so text is readable …

    thanks

  2. 3
    4
    5
    6
    7
    8
    9
    10
    11
    $custom_bg = array(
    ‘default-color’ => ”,
    ‘default-image’ => ”,
    ‘default-repeat’ => ”,
    ‘default-position-x’ => ”,
    ‘default-attachment’ => ”,
    ‘wp-head-callback’ => ‘_custom_background_cb’,
    ‘admin-head-callback’ => ”,
    ‘admin-preview-callback’ => ”
    );
    add_theme_support( ‘custom-background’, $custom_bg);

  3. How to use word press website for website

  4. This is such a great resource that me are providing and you give it away for free. seeing that understand the value of providing a quality resource for free

  5. Wow. cool post. I’d like to write like this too – taking time and real hard work to make a great article…

  6. You have posted a detailed document having full of latest information. I read this whole content and really liked it. Thanks for sharing.

  7. Thanks you very much for this code, you are great man 🙂
    Thanks for sharing.

  8. And can anybody suggest how to set the background background on each page?

  9. You probably need to connect some java script for this.

  10. Great article on wordpress theme. It is very useful for me.

  11. Thank you very much for the information you shared, it’s all I’ve been looking for

  12. Interesting article! Thank you for sharing them! I hope you will continue to have similar posts to share with everyone!

  13. One thing that is not here that I think should be part of this game, click on it and play it. Your spirit will improve after a day of hard work and study. Have fun! 

  14. With online chat almost anyone has the power to connect instantly with others and in real time anywhere around the world about multiple topics.

  15. Thanks for the code. I solved my problem thanks to this pots.

  16. Make use of print postcards to do full justice to your bridal boutique business. cheap postcards printing

  17. It can also refer to the creation and distribution of solely electronic documents, such as PDF files or digital slideshows.. cheap printers

  18. I am actually amazed with your initiatives as well as actually pleased to see this post.

  19. I recently came across your blog and have been reading along. I thought I would leave my first comment. I don’t know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.

  20. Only you can make this world seem right. Only you can make the darkness bright.
    Only you and you alone. Can thrill me like you do And fill my heart with love for only you. Only you, only you can make this change in me. For it’s true you are my destiny When you hold my hand I understand. The magic that you do You’re my dream come true My one and only you.

  21. Just a smile and the rain is gone Can hardly believe it, yeah. There’s an angel standing next to me. Reaching for my heart Just a smile and there’s no way back .Can hardly believe it, yeah But there’s an angel calling me. Reaching for my heart I know that I’ll be okay now. This time, it’s real I lay my love on you It’s all I wanna do Every time I breathe I feel brand new You open up my heart Show me all your love and walk right through As I lay my love on you.

  22. This is really a nice and informative, containing all information and also has a great impact on the new technology. Check it out here:

  23. I recently came across your blog and have been reading along. I thought I would leave my first comment, Thanks for the code. I solved my problem thanks to this pots.

  24. Custom foundation is a WordPress include that enables you to alter foundation shading/picture from backend. Custom foundation gives your blog to a decent look. You can include default shading and picture. For empower custom foundation you need to utilize this capacity in your function.php document inside themeslug_setup() work.

  25. Subsequent to utilizing this you can see the foundation menu alternative under appearance menu. Ensure you subject header document have body_class() inside body tag and wp_head(); inside the head label this way: So at whatever point you can include foundation shading or picture this capacity can create a style inside head tag and it will abrogate your topic template. Presently let me demonstrate to you a few capacities which permits you set up default shading and picture.

  26. The information you share is very useful. It is closely related to my work and has helped me grow. Thank you!

  27. Yes, the article I was looking for. Your article gives me another approach on the subject. I hope to read more articles from you.

  28. You will find a lot of approaches after visiting your post. I was exactly searching for. Thanks for such post and please keep it up. Great work!!

  29. Let me take a nap… great atmosphere, anyway.

  30. Pattern, playfulness, concept, shot – radiant.

  31. Ceativity and the post clarity is awesome! I believe there are many who feel the same satisfaction as I read this article! I hope you will continue to have such articles to share with everyone!

  32. Your article is awesome! How long does it take to complete this article? I have read through other blogs, but they are cumbersome and confusing. I hope you continue to have such quality articles to share with everyone! I believe there will be many people who share my views when they read this article from you!

  33. I believe there are many other people who are interested in them just like me! How long does it take to complete this article? I hope you continue to have such quality articles to share with everyone! I believe a lot of people will be surprised to read this article! Thanks for your post!

  34. I recently came across your blog and have been reading along. I thought I would leave my first comment, Thanks for the code. I solved my problem thanks to this pots.

  35. Thank you for giving them this great knowledge, really thank you for sharing, hope you will have such great posts as this more.

  36. I found a lot of interesting information here. A really good post, very thankful and hopeful that you will write many more posts like this one.

  37. Wow – what an informative blog site – i need to spend more time here and intend to do so

  38. I am truly grateful to look at this sites content which contains useful information, thanks for offering similarly info.

  39. could you explain in wordpress how to add a background for a page rather than a post?

  40. I like your all post. You have done amazing execute. Thank you for the details you offer, it reduced the issue a lot. I want many more details or so from you.

  41. Thank you for giving them this great knowledge, really thank you for sharing, hope you will have such great posts as this more

  42. Thank for sharing.Your article is awesome! How long does it take to complete this article? I have read through other blogs, but they are cumbersome and confusing.
    I hope you continue to have such quality articles to share with everyone! I believe there will be many people who share my views when they read this article from you!

  43. Those who come to read your article will find lots of helpful and informative tips

  44. This was a great and interesting article to read. I have really enjoyed all of this very cool information

  45. Thank you for this great article.

  46. This was a great and interesting article to read. I have really enjoyed all of this very cool information

  47. Hi, I desire to subscribe for this web site to obtain most up-to-date updates, so where can i do it please help.

  48. very good and important to me this great article

  49. Thank for sharing.Your article is awesome! How long does it take to complete this article? I have read through other blogs, but they are cumbersome and confusing.

  50. Hi buddy, your blog’ s design is simple and clean and i like it. Your blog posts about Online Dissertation Help are superb. Please keep them coming. Greets!!

  51. Very useful info, thanks!

  52. Outstanding, This is very awesome and awesome brief material. when I just analysis these records. Get more details. So I like it. Thank you to build up types of with us.

  53. I am very thankful to look at the post,it is very well released.You have done attempt released information and i pleased your perform.

  54. Hi, I really like the new site!! I know how a lot of your, regarded, and serious take it out needs for example another web a way to fulfillment. You’ve done it.

  55. Pretty helpful material, much thanks for this article

  56. Custom background is a WordPress feature that allows you to customize background color/image from backend. Custom background gives your blog to a nice look.

  57. I’m really impressed with your article, such great & usefull knowledge you mentioned here

  58. I Appreciate This Work Amazing Post For Us I Like It.

  59. nice and informative blog.

  60. Such a nice post, keep up the fantastic work

  61. Ready? Click a บาคาร่า gclub directory and start choosing the best online games casinos you can find.

  62. I feel it interesting, your post gave me a new perspective! I have read many other articles about the same topic, but your article convinced me! I hope you continue to have high quality articles like this to share with veryone!

  63. This was a great and interesting article to read. I have really enjoyed all of this very cool information

  64. Things are very open and intensely clear explanation of issues. was truly information. Your website is very beneficial.

  65. Hi buddy, your blog’ s design is simple and clean and i like it. Your blog posts about Online Dissertation Help are superb. Please keep them coming. Greets!! Mechanical Engineering Homework Online Help

  66. I am actually amazed with your initiatives as well as actually pleased to see this post.

  67. Thanks for your article! I have read through some similar topics! However, your post has given me a very special impression, unlike other posts. I hope you continue to have valuable articles like this or more to share with everyone!

  68. hiii im riya can you meet me visit here

  69. Hi, great to see your website. I like the content and the research done behind every aspect of your blog. It looks great and very knowledgeable. Keep it up the good work.

  70. Good blog. Content sequence arranged very well.

  71. Good article and your way of explanation are awesome to understand.

Leave a Reply