WordPress.org

Ready to get started?Download WordPress

Forums

CSS image paths and other MIME type issues (3 posts)

  1. hellodaylight
    Member
    Posted 2 years ago #

    I've been having some trouble with my links to javascript, css and image files with a theme i'm developing. My console shows me that my js, css and image files are being interpreted as MIME type text/html, which obviously means they aren't working. I fixed the js and css links in my header by adding get_template_directory_uri() in the url, but I'm not sure how to fix my image paths in my CSS, as no matter what path I add, it seems not to work - absolute, relative, etc..

    I would love to know the reason why my paths aren't working. Here is my header linkage code:

    <link type="text/css" rel="stylesheet" href="http://code.jquery.com/mobile/1.0rc2/jquery.mobile-1.0rc2.min.css" />
    	<link type="text/css" rel="stylesheet" href="style.css"  />
    
    	<script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/js/klass.min.js"></script>
    	<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
    	<script type="text/javascript" src="http://code.jquery.com/mobile/1.0rc2/jquery.mobile-1.0rc2.min.js"></script>
    	<script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/js/code.photoswipe.jquery-3.0.4.min.js"></script>
  2. peredur
    Member
    Posted 2 years ago #

    In general, all references to files should be absolute in WP. The only exception is in a style sheet, where references are relative to the style sheet. You can usually get what you want in your HTML file using bloginfo() and the appropriate parameter concatenated to what remains of the path.

    Just use relative paths in ur() calls in style sheets.

    Cheers

    PAE

  3. Chip Bennett
    Theme Review Admin
    Posted 2 years ago #

    Why are you linking jQuery from an external library, when WordPress bundles/enqueues its own version? That will almost always cause issues/conflicts/unintended consequences.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.