1

i got a custom template with blog post in it...

In my header.php, inside the <head> i have my links like this ...

<link href="http://www.mysite.com/css/design.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="http://www.mysite.com/js/myjs.js"></script>

those links are working in my custom template.. by using

<?php get_header(); ?>

All blog post in my custom page are there.. no layout problems.

But when i click one of the post. my layout is broken. and when i checked it via Inspect Element. the link is like this

<link href="http://www.mysite.com/blog/css/design.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="http://www.mysite.com/blog/js/myjs.js"></script>

* EDIT * from the answers below, above is my original question, anyway my problem is still the same.

I added this to my functions.php and removed the links on my header.php also i copied the files inside the wordpress folder called links...

/httpdocs/blog/wp-content/themes/myblog/links

    // Get Links 

    function theme_scripts_styles() {

  wp_enqueue_style( 'my-styles', get_stylesheet_directory_uri() . '/links/design.css', array(), '1.0', 'all' );

  wp_enqueue_script( 'my-scripts1', get_stylesheet_directory_uri() . '/links/cufon-yui.js', array(), '1.0', true );

  wp_enqueue_script( 'my-scripts2', get_stylesheet_directory_uri() . '/links/232MKSD_200.font.js', array(), '1.0', true );

  wp_enqueue_script( 'my-scripts3', get_stylesheet_directory_uri() . '/links/232MKSDB_400.font.js', array(), '1.0', true );

  wp_enqueue_script( 'my-scripts4', get_stylesheet_directory_uri() . '/links/fonts.js', array(), '1.0', true );

  wp_enqueue_script( 'my-scripts5', get_stylesheet_directory_uri() . '/links/OpenSans_400.font.js', array(), '1.0', true );

  wp_enqueue_script( 'my-scripts6', get_stylesheet_directory_uri() . '/links/OpenSansSB_600.font.js', array(), '1.0', true );



}

 add_action( 'wp_enqueue_scripts', 'theme_scripts_styles' );
8
  • 1
    That is a significant edit. How much have you changed int he code in response to answers below? Is the problem still the same as when you first posted?
    – s_ha_dum
    Commented Aug 26, 2013 at 15:12
  • I'm joining to the @s_ha_dum's question, does it work now or you still have problem?
    – iEmanuele
    Commented Aug 26, 2013 at 15:26
  • same problem.. even though i already followed the answers below. Commented Aug 26, 2013 at 15:31
  • another thing that comes to mind is: have you made the call to wp_head(); and wp_footer(); ? Respectively in header.php and footer.php.
    – iEmanuele
    Commented Aug 26, 2013 at 15:33
  • 1
    its my .htaccess file ... i deleted it. then went to permalinks and saved it again. it fixed the problem.. so all answers here are correct even my code above is i think also correct. Commented Aug 26, 2013 at 16:28

1 Answer 1

0

My guess is that you are using relative URLs in your header.php file. That would explain the difference in the paths. (It is probably differnt on archive pages too, right?) Don't do that. Relative URLs do not work well in a WordPress context. Generally, you want to use get_permalink(), site_url(), home_url(), etc. to create absolute URLs. For the template files you want get_template_directory_uri() and get_stylesheet_directory_uri().

I am guessing that you are also not registering and enqueueing the stylesheets and scripts.

See:
http://codex.wordpress.org/Function_Reference/wp_register_script
http://codex.wordpress.org/Function_Reference/wp_enqueue_script
http://codex.wordpress.org/Function_Reference/wp_register_style
http://codex.wordpress.org/Function_Reference/wp_enqueue_style

1
  • Hi, i edited my question.. please see the code. Commented Aug 26, 2013 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.