I am working in the theme called Understrap. I work in the child-theme. The theme

allready has a style.css and functions.php. I want to create my own style.css file

and overwrite that style.css they have included. Any suggestions?

Thank you very much

  • you can simply replace it if you don't want to use the one given at all. back it up just in case you want to revert. if you want to use an additional style sheet. create a css file with any name and enqueue it developer.wordpress.org/reference/functions/wp_enqueue_style – inarilo Mar 29 '18 at 10:40
  • The template allready has an functions.php file, should i use that one or create my own functions.php? – Mustafa Dennis Uslu Mar 29 '18 at 11:07
  • you are asking about a specific theme that no one here is likely to know anything about. In addition there is no code that you have tried, so people can't do more than guessing. It is not clear at all what is the actual question here, is it about how to do such thing in general, best practice, or how to do it in the specific theme. That is why the downvote. – Mark Kaplun Mar 29 '18 at 18:23

Take a look at the official docs: https://codex.wordpress.org/Child_Themes https://developer.wordpress.org/themes/advanced-topics/child-themes/

Make sure you are within your child theme functions.php and use this code to make sure the function is firing. It will kill the page if it is working correctly.

  function wpdocs_theme_name_scripts() {
          wp_die('Yep! This is working');
    add_action( 'wp_enqueue_scripts', 'wpdocs_theme_name_scripts' );
  • hey i tried this, but still doesen't work. ` function add_theme_scripts() { wp_enqueue_style( 'style', get_stylesheet_uri() ); wp_enqueue_style( 'ownstyle', get_template_directory_uri() . '/owncss/ownstyle.css', array(), '0.2.0', 'all'); wp_enqueue_script( 'script', get_template_directory_uri() . '/js/script.js', array ( 'jquery' ), 1.1, true); if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } } add_action( 'wp_enqueue_scripts', 'add_theme_scripts' ); ` – Mustafa Dennis Uslu Mar 29 '18 at 17:43
  • @MustafaDennisUslu Updated my answer – Liam Stewart Mar 29 '18 at 17:50

You need to add following code to your child-theme's functions.php

     * Proper way to enqueue scripts and styles
    function wpdocs_theme_name_scripts() {
        wp_enqueue_style( 'style-name', get_stylesheet_uri() );
        wp_enqueue_style( 'custom-css', get_stylesheet_uri() . '/css/custom.css', array(), '1.0.0' );
        wp_enqueue_script( 'custom-js', get_stylesheet_uri() . '/js/custom.js', array(), '1.0.0', true );
    add_action( 'wp_enqueue_scripts', 'wpdocs_theme_name_scripts' );
  • hmm it doesent work, i might be doing something wrong: ``` ``` – Mustafa Dennis Uslu Mar 29 '18 at 14:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.