How to set a Background image in WordPress?

The way I see, you have 3 options:

  • You can achieve that with CSS. Just target the div you want to put the background in. Target it in a way that only shows at the home of the site (check the ID and class of the body div, it usually has names like ‘home-template’ and such.
  • You can achieve that with HTML. You can ‘hard-code’ the style inline, in your PHP file, like you would do in a HTML one. You can do that, if the body of the document is in a file that is not header.php.
  • (recommended) You can achieve that with PHP using ‘is_front_page’ (https://developer.wordpress.org/reference/functions/is_front_page/). Just do a conditional that checks if the page is the front page. If it is, you can attach and ID to the body, or style it inline. Else, just use the regular body.