WordPress.org

Forums

can you have different background pictures (4 posts)

  1. monkey50
    Member
    Posted 3 years ago #

    i would like to add different background pictures to different pages can this be done

  2. alchymyth
    Forum Moderator
    Posted 3 years ago #

    your theme might be using body_class() which gives specific css classes for each page, for instance: .page-id-123 with the page ID as numbers;

    in style.css, use it for example:

    body.page-id-123 { background: url(images/page123backgr.jpg); }
    body.page-id-159 { background: url(images/page159backgr.jpg); }

    or add conditional styles into the head section of your theme (in header.php);

    example:

    <style type="text/css">
    <?php if( is_page(123) ) : ?>
    body.page-id-123 { background: url(<?php echo get_stylesheet_directory_uri(); ?>/images/page123backgr.jpg); }
    <?php elseif( is_page(159) ) : ?>
    body.page-id-159 { background: url(<?php echo get_stylesheet_directory_uri(); ?>/images/page159backgr.jpg); }
    <?php endif; ?>
    </style>

    details depend on the currently used theme.

  3. monkey50
    Member
    Posted 3 years ago #

    would that be on wordpress to change it or do i go to my host file manager like that

  4. alchymyth
    Forum Moderator
    Posted 3 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags