• Resolved Jam

    (@pimaniii)


    I have a custom template that I wrote with php. How can I write custom css to control it?

    I obviously don’t want to edit the main css (in case of a theme update). I’m a bit new to how php and css work together here.

    Thanks!

Viewing 15 replies - 1 through 15 (of 17 total)
  • A child theme would be the way to make those kinds of changes to a theme –

    https://codex.www.ads-software.com/Child_Themes

    Just add your new CSS to the site. If your rules are suitably specific, they shouldn’t impact on other areas of the site. Are you using a child theme or a custom CSS plugin?

    Thread Starter Jam

    (@pimaniii)

    I am now using Custom CSS Manager.

    My question is how can I control elements on a specific page template with css without touching other pages. CSS changes I make appear to alter other page templates as well.

    Then your CSS is not specific enough. I’m sorry but it is really beyond the scope of these forums to deal with general CSS issues. Try a dedicated CSS resource such as https://www.css-discuss.org/ instead. In the meantime, try using Firefox with the Firebug add-on for this kind of CSS work. Or use whatever developer tool is available in your web browser.
    https://getfirebug.com/

    Look in the body tag – there should be page-specific class that you can use as part of the CSS selector for those styles.

    Thread Starter Jam

    (@pimaniii)

    Got it! Thanks!

    Quick sidenote on child themeing: Is it generally ‘ok’ to make changes to internal php files or is there a better way to go about this?

    Thanks!

    You shouldn’t make any changes to any of the parent theme’s files.

    Any changes you make to parent theme files will be overwritten when the theme is updated. You should put copies of .php files in the child theme and make changes there. Exception is functions.php – read the linked page on how to do that – don’t put a copy in the child theme as it WILL crash the site :).

    EDIT- just to clarify – only put copies of the files you are changing in the child theme.

    Thread Starter Jam

    (@pimaniii)

    Ok got it. Thanks a bunch! I know this is a bit beyond the scope, but when the parent files update, say the php file that is in my child theme was updated in the parent, how does that change get made on the site if my child theme is covering it up?

    When it comes to updates, your child and its parent theme are completely separate. The parent theme will be updated but your child theme will not be touched.

    Thread Starter Jam

    (@pimaniii)

    Ok last question!

    Say I have made many changes to a theme directly. In order to make those changes on a new child theme can I do the following?

    Re-download a clean install of the theme and call that my parent theme. My active theme with the changes will be my new child theme. This way all the changes will be made! I will remove all duplicated files.

    Is this practice valid?

    Thread Starter Jam

    (@pimaniii)

    I will also remove all duplicate lines of code and only keep the changes I made. I figure this way I will be able to go through my changes a lot faster

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    Ok last question!

    I hope not. This is a support forum after all. ??

    Say I have made many changes to a theme directly. In order to make those changes on a new child theme can I do the following?

    Save that modified directory and restore a fresh untouched version of the parent theme.

    Make a new child theme and try putting in only the files you modified. Hopefully you did not modify the functions.php file, that can get sticky.

    If your changes are is default files such as header.php or footer.php then copying those modified files into your child theme directory should work.

    Thread Starter Jam

    (@pimaniii)

    Awesome. I’m doing that now. Unfortunately I did make additions to functions.php. Can I simple add them in?

    Also the theme I’m ‘childing’ uses a more complex css styling. It has a basic style.css but then uses other css files in a subdirectory to style is pages. I have edited those. Can I simple put those files in my child theme (in the same directory structure) with my edits only or do I need to copy the entire file?

    Thanks a bunch.

    Thread Starter Jam

    (@pimaniii)

    Can I simply @import the old file, and write in only the changes / additions I have made?

    What about other php files?

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Custom CSS On Single Page Template’ is closed to new replies.