• Resolved mzimmers

    (@mzimmers)


    Hi –

    I’m trying to reference two style sheets from my header.php file. It’s my understanding that this is OK in general, so I assume it would work within WP. Here’s the inclusion code:

    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
    
    <link rel="stylesheet" href="<?php echo(TEMPLATEPATH . "/hornady.css"); ?>" type=text/css" />

    I wrote the second line myself, and I’m still a beginner at PHP. Can anyone see what’s wrong (if anything)? Oh: the hornady.css file is in the same directory as all of my theme templates.

    Thanks…

    PS: https://www.scopedin.com/wordpress

Viewing 7 replies - 1 through 7 (of 7 total)
  • why don’t you call it directly and not use the php?

    Thread Starter mzimmers

    (@mzimmers)

    I’m not sure I know what you mean…are you talking about an #include statement? Sorry if I’m being obtuse, but I’m new at this.

    though that file (header.php) is a php file, it works like a template (.tmp, .template, ect) so you can call to the css just as if you would in a regular html page.

    drewactual, I believe the goal here is to add some dynamic functionality to the url in the href.

    mzimmers, your stuff looks fine (TEMPLATEPATH is a WordPress constant which defines the location of the active theme directory, so it’s the right one to use here), but I’m not sure what your question is. Are you asking if it’s ok to use 2 (or more) stylesheets at the same time? If that is your question, then yes, it’s ok.

    Thread Starter mzimmers

    (@mzimmers)

    Kafkaesqui – yes, that was my original question. I had a malformed text string in my <link> statement originally, but that’s now fixed. For some reason, though, the TEMPLATEPATH constant is pointing to a bad directory structure:

    <link rel="stylesheet" href="/home/scopedin/public_html/wordpress/wp-content/themes/pure-12/hornady.css" type="text/css" media="screen">

    Odd that I’d get the “home/scopedin/etc…” since 1) I don’t have a home directory, and 2) the call to bloginfo returns a different (correct) path.

    Where is TEMPLATEPATH defined? I may have screwed something up there…

    Update: I see it’s in wp-settings.php and is defined by a call to get_template_directory(), which is less than fully documented. I may have to hard-code this after all.

    Actually, *I* screwed up in stating it looked fine.

    TEMPLATEPATH does define the full directory path to the template (i.e. theme) directory, but you should instead be printing out the URL to it for the href. This will work far better:

    <link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/hornady.css" type=text/css" />

    Thread Starter mzimmers

    (@mzimmers)

    Excellent! Thanks, Kafka. In the meantime, I’ve come to a decision on this theme, so I’m going to mark this resolved and open another issue. I appreciate the help.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘multiple style sheets OK?’ is closed to new replies.