• Resolved flamy

    (@flamy)


    Hi,

    I’d like to include a few css files and js files so that they are available just to my posts. I don’t need them on the rest of my site, so it is needless to load them in the main header.

    I’m including them at the top of every post like this:

    <link rel="stylesheet" href="paypal/jqtransformplugin/jqtransform.css" type="text/css" />
    <link rel="stylesheet" href="paypal/download.css" type="text/css" />
    <script type="text/javascript" src="paypal/jqtransformplugin/jquery.js" ></script>
    <script type="text/javascript" src="paypal/jqtransformplugin/jquery.jqtransform.js" ></script>
    <script type="text/javascript" src="paypal/download.js" ></script>

    Is there a better way? Presumably the best way would be to put some sort of a clause in the <head> like “if page is a post page include css+js files”. Any suggestions?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Jonas Grumby

    (@ss_minnow)

    Use a Conditional Tag so that the output is only included on posts. You can also keep the CSS and JS in external files and use a php include to call them in on those pages rather than putting all of the code directly into the header.php.

    Thread Starter flamy

    (@flamy)

    Brilliant just what I was after. Thank you.

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

The topic ‘CSS & JS files within post’ is closed to new replies.