• Hi. My question is simple: how to get the theme directory.
    I was developing an website in wordpress, that in my localhost it was:
    localhost/sites/project_name/

    so, in my header.php I put the css path:
    <link src=”/sites/project_name/wp-content/themes/my_theme/css.css”

    but, when I send it to other developer, his address structure was:
    localhost/projects/blalba/project_name/

    then wordpress couldn’t find the css.

    so, how to dynamically get my current template`s root directory path?

    thanks.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Try this.
    <?php bloginfo('template_directory');?>/css.css

    Thread Starter anothertrad

    (@anothertrad)

    Thanks. it works.
    But please, show me the link of the documentation of his useful bloginfo functions.
    Thanks again.

    Thread Starter anothertrad

    (@anothertrad)

    There`s a way to get the plugin directory?

    if(function_exists('plugins_url')){
    	$plugin_url = plugins_url($plugin_dir . '/');
    }else{
    	$plugin_url = get_bloginfo('wpurl') . '/'
    	. (defined('PLUGINDIR') ? PLUGINDIR . '/': 'wp-content/plugins/')
    	. $plugin_dir . '/';
    }
    Thread Starter anothertrad

    (@anothertrad)

    got it

    Thread Starter anothertrad

    (@anothertrad)

    Let me tell you something about this function bloginfo(‘template_directory’).
    For me, it returns: “localhost:8888/sites/project_name/wp-content/themes/my_theme/”
    Everything ok.
    When I open my wordpress project trought another computer in the network, I put my_ip:8888, like:
    192.168.0.4:8888/sites/project_name

    when I go to the code, I expect that the function bloginfo(‘template_directory’) returns to me:
    “192.168.0.4:8888/sites/project_name/wp-content/themes/my_theme/”

    Instead, it returns:
    “localhost:8888/sites/project_name/wp-content/themes/my_theme/”

    Maybe it`s a site-name configuration in apache?

    well, maybe if I remove the characters before the first slash, it may be work…

    Thread Starter anothertrad

    (@anothertrad)

    I wrote a little function to remove “localhost:8888” from the address, leaving the relative directory.

    But the function wp_head() stills put localhost:8888 in front of the css links, and I`m afraid that I can’t change this, right?

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘How to dynamically get theme directory?’ is closed to new replies.