WordPress.org

Ready to get started?Download WordPress

Forums

The Bootstrap
[resolved] Custom Bootstrap build in child theme (6 posts)

  1. Magical1
    Member
    Posted 1 year ago #

    How do I link up a custom build of bootsrap.css to my child theme I have looked at
    the_bootstrap_print_styles();
    but I cannot work out where I should be making changes.

    Any help or advise would be much appreciated!

  2. Magical1
    Member
    Posted 1 year ago #

    Obviously I can just copy my custom build of bootstrap.css to the-bootstrap theme /css folder, but I was hoping to get this to work in my child theme /css folder, that way updates of the parent theme would not overwrite it, until I manually updated the bootstrap.css.

  3. jmjf
    Member
    Posted 1 year ago #

    I think what you want is in the_bootstrap_register_scripts_styles. The sequence of linked files here seems to match if I make allowances for plugins.

    See codex for get_template_directory_uri at http://codex.wordpress.org/Function_Reference/get_template_directory_uri which warns that the function gets the parent's directory, not the child's and gives an alternate function.

    But it would be nice if there was a way to set this in the theme customizer. If nothing else, you could point to a differently named bootstrap.min.css in the-bootstrap/css. Updating the parent shouldn't overwrite it. (Should also be able to set the version in case people update bootstrap.css out of sync with the parent theme. And of course, all the bootstrap files should be included.)

    Take a look at theme-customizer.php in the-bootstrap/inc. It isn't hard to add things here. You'd need to modify the function above to use the values you set. Once you have it working, submit it on git so Konstantin can pick it up.

  4. jmjf
    Member
    Posted 1 year ago #

    Thought. Simple way to handle this would be to have a radio button option in customizer -- use parent CSS/JS or use child CSS/JS. Based on that call the appropriate function in the_bootstrap_register_scripts_styles to set a variable, then use the variable instead of calling the get_template_directory_uri throughout the function. Note using child theme directory might create problems for bootswatch styles, but those of us using custom (and current, 2.2.2) bootstrap.css probably don't care.

    If you don't get to it sooner, I may try to tackle this in the next week or two and put it on git.

  5. jmjf
    Member
    Posted 1 year ago #

    Or, add a new theme option for "child theme css" like the bootswatch options. That's really what's going on here.

    (I guess I'm making notes to myself here in case I do this.)

  6. jmjf
    Member
    Posted 1 year ago #

    Changes that work in my test environment submitted to github.

    Note that these changes expect to find the following files in the child theme.
    css/bootstrap(.min).css
    css/bootstrap-responsive(.min).css
    js/bootstrap(.min).js

    https://github.com/jmjf/the-bootstrap/commit/3939244b587b32c8d44a06fd1940068e5a805ba3

    https://github.com/jmjf/the-bootstrap/commit/5337ad2c6168337515c8536b9159965e968d1842

    Note comment on the last commit which explains what actually changed since github seems to have gotten lost in the diff.

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic