Dorcas
Dorcas

Reputation: 1

Wordpress theme background-image

I am creating a wordpress theme and trying to set a custom background image and allow an admin to change the background image, but my image is not appearing. What can be missing?. Below is my functions.php

<?php
function scripts_enqueue() {
    wp_enqueue_style('body',get_template_directory_uri().'/css/styling.css',array(),'1.0.0 ','all');
}
add_action('wp_enqueue_scripts','scripts_enqueue');
function theme_setup() {
    add_theme_support('menus');
    add_theme_support('custom-background');
}
add_action('init','theme_setup');
register_nav_menu('Main Menu','Main menu');
register_nav_menu('Footer Menu','footer menu');
?>

Upvotes: 0

Views: 131

Answers (1)

user1575941
user1575941

Reputation:

(1)

Add theme support on the after_setup_theme action, and provide defaults:

function my_custom_background_setup() {
  $args = array(
    'default-color' => 'FFFFFF',
    'default-image' => '',
  );
  add_theme_support( 'custom-background', $args );
}
add_action( 'after_setup_theme', 'my_custom_background_setup' );

(2)

Remember to call body_class() in your header.php:

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

Upvotes: 1

Related Questions