How to add css to php files in "Converting HTML site to wordpress"

by 2 replies
3
I've figured out how to converting HTML site to wordpress but css files are missing so site looks bad. I've found this today Tools to selectively copy HTML+CSS+JS from existing sites - Stack Overflow (scroll down for solution)
Now I think that I need to add css to php files that I've already added HTML.How do I do that?
or is there another way to add css
#website design #add #css #files #php
  • You have to use wp_enqueue_style(); Function at the bottom of functions.php

    Like this one:
    PHP Code:
    function theme_name_scripts() {
        
    // Add Bootstrap CSS
        
    wp_enqueue_style'bootstrap'get_template_directory_uri() . '/css/bootstrap.min.css', array(), '1.0' );

        
    // Theme stylesheet / Style.css.
        
    wp_enqueue_style'theme-style'get_stylesheet_uri() );
    }
    add_action'wp_enqueue_scripts''theme_name_scripts' ); 
    You also have to use bellow code for linking index.php with functions.php
    <?php wp_head(); ?> before </head> tag,
    <?php wp_footer(); ?> before </body> tag.
  • Banned
    The CSS stylesheet has to be in the Wordpress theme folder and named style.css. It can't have any other name.

    ...after that just link to the style.css file like usual in the HTML <head>.

    You can add other stylesheets with custom names but WP is looking for that specific name. This is all in the WP documentation, Google it.

Next Topics on Trending Feed

  • 3

    I've figured out how to converting HTML site to wordpress but css files are missing so site looks bad. I've found this today Tools to selectively copy HTML+CSS+JS from existing sites - Stack Overflow (scroll down for solution) Now I think that I need to add css to php files that I've already added HTML.How do I do that? or is there another way to add css