• Resolved Sub_Zero

    (@sub_zero)


    Hi

    My css file can’t get loaded.

    Code:
    wp_enqueue_style('roots_app', '/assets/css/app.css', false, null);

    Location:

    C:\xampp\htdocs\akorug\wp-content\themes\akorug\assets\css\app.css

    Source
    <link rel="stylesheet" href="/akorug/assets/css/app.css">

    It shows me simply a 404 page. What am I doing wrong?

Viewing 11 replies - 1 through 11 (of 11 total)
  • I am unclear on what you are trying to do. Would you mind posting what you are trying to accomplish and the steps you are taking?

    Thanks,
    Don

    Thread Starter Sub_Zero

    (@sub_zero)

    I am just trying to bind my css file.

    This is what my browser shows me in the source code: <link rel=”stylesheet” href=”/akorug/assets/css/app.css”>

    The css file doesn’t get loaded though. If I click on “/akorug/assets/css/app.css” in the source-view, I get forwarded to a 404 page.

    Have you checked in File Manager or FTP that the file is there?

    My guess is that it’s doesn’t load because the url is relative.

    Try an absolute url like this instead:

    $fullURL = get_bloginfo( 'template_url' ) . '/assets/css/app.css';
    
    wp_enqueue_style( 'roots_app', $fullURL, false, null);
    Thread Starter Sub_Zero

    (@sub_zero)

    @donhoward The file definitely exists. Because if I run the following path on my browser, I get the css file opened with my editor: C:\xampp\htdocs\akorug\wp-content\themes\akorug\assets\css\app.css

    @chris I tried that code but it still doesn’t change anything. My CSS can’t still get loaded.

    Thread Starter Sub_Zero

    (@sub_zero)

    No, that’s a 404.

    Thread Starter Sub_Zero

    (@sub_zero)

    That’s a good sign. Apache is still working.

    I think Chris is on the right track. What you’ve mentioned points to the app.css file being located at http://localhost/akorug/wp-content/themes/akorug/assets/css/app.css when called from a browser.

    You should be able to paste that in your browser and read the .css file. The 404 can mean a couple of things. Either the file isn’t being saved where you think it is, or your editor is saving it in a format that the browser doesn’t recognize, or doesn’t match the type of file be called.

    This seems a bit confusing:

    “Because if I run the following path on my browser, I get the css file opened with my editor: C:\xampp\htdocs\akorug\wp-content\themes\akorug\assets\css\app.css”

    A) use windows explorer, rather than your browser to navigate to C:\xampp\htdocs\akorug\wp-content\themes\akorug\assets\css\ and actually put your eyes on the file to verify that it’s still where it should be.

    B) if it is, then expose the file extension to make sure it’s being saved properly. Even if it was being saved as a .txt file, your browser should still open it (but it would give a 404 error if the request was for a .css file, and not .txt file).

    If the file is located at \htdocs\akorug\wp-content\themes\akorug\assets\css\, and Apache can serve other files in the same directory and they render properly in your browser, then it would seem the only variable left might be the file itself (or it’s extension). Very strange.

    Thread Starter Sub_Zero

    (@sub_zero)

    @claytonjames thank you for trying to help. I was able to solve this problem now. Since this theme ALWAYS worked for me, I couldn’t imagine that there is something wrong with the code. So I reinstalled WordPress, just to make sure WordPress is not fooling. Then I realized even the CSS of WordPress is not getting loaded. So the problem was XAMPP. I don’t know what exactly was wrong with it but after I reinstalled XAMPP, everything worked perfectly and all CSS files could get loaded normally.

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘CSS returns 404’ is closed to new replies.