WordPress.org

Ready to get started?Download WordPress

Forums

Setting a diferent Page BG for various templates (4 posts)

  1. gqelements
    Member
    Posted 1 year ago #

    Hi i'm an absolute novice and although have found multiple similar(ish) queries on this, am not able to follow the directions, so hoping someone can assist with exact code I can cut+paste to achieve the desired effect.

    I'm trying to set-up that "Full-width" Page Template to use a different BG Image compared to main page and other templates.

    Let's say the file is location/fileA.png

    Could someone please help me with exact code (and where to insert it, in which of the files) to achieve this?

    Very lost and frustrated, hope someone can assist!

    Main Page: http://dev.dsokolov.ca/
    Page that needs alternate BG: http://dev.dsokolov.ca/?page_id=18 (using 'fullscreen' template.

  2. hieu.nguyen
    Member
    Posted 1 year ago #

    First you have to create a new page template for that special page.

    You can duplicate the current page.php, and name the new file page-a.php for example.

    Then at the beginning of that new file, add this
    /**
    * Template Name: YOUR NEW TEMPLATE NAME
    *
    */

    This will allow you to select the new template from the back-end.

    In that new template, you also have to assign a new class to <body>, say class background-a

    Then you have to add css.
    body.background-a { background:url(location/fileA.png) no-repeat; }

  3. alchymyth
    Forum Moderator
    Posted 1 year ago #

    your theme uses body_class() http://codex.wordpress.org/Function_Reference/body_class

    - therefore you will have page template specific css classes in the body tag of pages which are using a template;

    example:

    .page-template-fullwidth

  4. gqelements
    Member
    Posted 1 year ago #

    Thanks to both posters, and esp. to alchymyth, as your post lead me to the solution, achieved through translucent BG

    The next challenge is to Get RID of the (now left blank) container of the front page....

    Can anyone suggest what TEMPLATE governs my index page? Subsequently I will need to edit to somehow delete any references to CONTENT div or container (to get rid of that translucent box from the Index page only...

    I tried looking a the source of the page but can't quite figure it out...

    Thanks so far for all the help, this is fun!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.