WordPress.org

Ready to get started?Download WordPress

Forums

Custom theme settings not appearing (3 posts)

  1. pjb007
    Member
    Posted 1 year ago #

    I have looked at many tutorials for making a WordPress theme and each one I try results in the same problem.

    The options appear in the admin area but are never applied to the website. When I reload the page in the admin area the settings are remembered.

    As a simple start to WordPress I thought making a custom background would be a good idea. Can anyone help?

    As various tutorials suggest I've added code like the below to a functions.php file

    add_theme_support( 'custom-background', array(
    		'default-image' => get_template_directory_uri() . '/images/bg.jpg',
    	) );

    Since adding this the options for the background are appearing on my admin panel. How do I get these settings to apply to the website itself?

  2. atul1280
    Member
    Posted 1 year ago #

    You need to output them to your theme. For example, in Twenty Twelve theme it is like this:

    <?php $header_image = get_header_image();
    if ( ! empty( $header_image ) ) : ?>
    <a href="<?php echo esc_url( home_url( '/' ) ); ?>"><img src="<?php echo esc_url( $header_image ); ?>" class="header-image" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" /></a>
    <?php endif; ?>
  3. pjb007
    Member
    Posted 1 year ago #

    Sorry if I was not clear its for the body background image/colour I am trying to do this.

    I assume that my first bit of code correct then?

Topic Closed

This topic has been closed to new replies.

About this Topic