I am creating a theme, and now I am adding some functionality for my custom post type, such as different metaboxes in post page, extra post config page.

It seems when I try to get the sites theme directory so I can enqueue a custom css file and php file for the seperate post page I am getting FTP root folders in the url, causing it to 404.

Here is the way I am adding it. I have a seperate file with all of the custom post type functions in it, and I am adding it as a dependency through my functions.php. I wanted to go with the separate file, for neatness so I don't have a million functions in my functions.php. I also have a css file in a folder inside of my includes dir. The CSS is for the backend, for the custom post pages in the admin.

EDIT: I just checked and it adds the FTP root info even if I manually add the path instead of a function(get_template_directory()), now this really confuses me as all of the functions anywhere else work fine, just in this file with the post_type functions. I have other post_type functions in my functions.php folder and they work fine too. Anyone care to lend a brain?

When using get_template_directory() :

wp_register_style('PostTypeStyleSheet', get_template_directory() . '/inc/post-types-functions/css/cpadminstyles.css');
wp_enqueue_style( 'PostTypeStyleSheet');

I get a url like this back:

Failed to load resource: the server responded with a status of 404 (Not Found) http://mythemesite.com/home2/jname/public_html/sandbox/wp-content/themes/mytheme/inc/post-types-functions/css/cpadminstyles.css?ver=3.5.1

I am not sure why this is happening, I use get_template_directory() almost everywhere else and do not have this issue. Can anyone tell me why it could be happening?

  • Are you using a child theme concept, if not can you add the theme folder structure Commented Dec 9, 2013 at 19:07
  • No Child theme. I just checked and even if I add the URL manually without using get_template_directory() it does the same. I am a little confused. Commented Dec 9, 2013 at 19:08
  • can you check the file permission then? Commented Dec 9, 2013 at 19:11

1 Answer 1


You should use get_template_directory_uri()

wp_register_style('PostTypeStyleSheet', get_template_directory_uri() . '/inc/post-types-functions/css/cpadminstyles.css');
wp_enqueue_style( 'PostTypeStyleSheet');
  • how did I miss it(facepalm).. +1 Commented Dec 9, 2013 at 19:22
  • wow! I feel the same way. The two had me confused, I had actually dealt with this before. Oops. Commented Dec 10, 2013 at 2:09

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.