WordPress.org

Ready to get started?Download WordPress

Forums

Custom CSS file per page template (8 posts)

  1. Mohidul Islam
    Member
    Posted 1 year ago #

    Hello everybody,
    Help me please. I am using twentyten theme. I wanted to create some custom page like About Us, Login, Register etc.
    Page template has been created. But problem is the css file. When I created a div id or class. And write some styles. There have no changes.
    Now how can I write stylesheet for my custom page template.
    What Can I Do Now ?
    Regards,
    Mohidul Islam

  2. serpico
    Member
    Posted 1 year ago #

    I would suggest adding the custom styles to the usual style.css file. You can apply your CSS code to specific pages by selecting elements using the body class. Details of this can be found within the codex here:
    http://codex.wordpress.org/Function_Reference/body_class

  3. Mohidul Islam
    Member
    Posted 1 year ago #

    Thanks for you reply serpico .
    I am try to add styles in style.css. But doesn't work. What can I do for work in style.css file.

  4. Mohidul Islam
    Member
    Posted 1 year ago #

    My custom page is about.php

  5. serpico
    Member
    Posted 1 year ago #

    Can you provide a link to your custom about page?

  6. Mohidul Islam
    Member
    Posted 1 year ago #

    Oh reasy sorry serpico,
    That is my localhost.

  7. serpico
    Member
    Posted 1 year ago #

    Take a look at the source code, you will see the body tag has a number of classes. One of these will be a specific page id.

    For example, you can then use the CSS:

    body.page-id-4 #wrapper { background-color:#000 !important }

    This will select the tag with an ID wrapper within the Page ID 4.

  8. Arie Putranto
    Member
    Posted 1 year ago #

    Or you can add another stylesheet to your theme directory and load it using conditional tags.

    For example:

    On your function.php

    // Replace # with the ID of your custom page

    if ( is_page( # ) ) {
    wp_enqueue_style( 'path/to/your/custom/css/file' );
    }
    else wp_enqueue_style( 'path/to/your/original/css/file' );

    But if you only add minor change to the style, @serpico way would be proper.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.