WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] get_template_directory_uri() issues with sub-directory theme (7 posts)

  1. WebMaestro.Fr
    Member
    Posted 2 years ago #

    Hi there !

    Well, my main install is under http://www.site.com/blog,
    my sub-directory install is under http://www.site.com/blog/travels.

    Within the theme "Roots",
    echo get_template_directory_uri();
    give me
    /blog/travels/wp-content/themes/roots
    ... all good.

    But,
    wp_enqueue_style('roots_bootstrap', get_template_directory_uri() . '/css/bootstrap.css', false, null);
    give me
    <link rel="stylesheet" href="/blog/travels/blog/travels/wp-content/themes/roots/css/bootstrap.css">

    Curious isn't it ?!

    Same for the stylesheets called from the plugins, but only with this theme ! The same plugin's stylesheets called from another theme (TwentyEleven) works fine !

    Could it be an URL rewriting somewhere ? My .htaccess seems find with the other themes.

    I would appreciate your help on that one folks.

  2. WebMaestro.Fr
    Member
    Posted 2 years ago #

    Okay, the problem was coming from the theme, of course.

    To avoid this, modify /wp-content/themes/roots/inc/config.php
    and just turn those two lines (6 and 7) to comments :

    // add_theme_support('root-relative-urls');    // Enable relative URLs
    // add_theme_support('rewrite-urls');          // Enable URL rewrites

    Fixed the problem for me.

  3. floq-design
    Member
    Posted 1 year ago #

    Great find.
    Many thanks

  4. xcded
    Member
    Posted 1 year ago #

    Don't forget to use
    <?php wp_head(); ?>
    in your header.php

  5. sb_surinder
    Member
    Posted 1 year ago #

    Thank You

  6. a2d
    Member
    Posted 1 year ago #

    +1

  7. robheath
    Member
    Posted 1 year ago #

    Thanks, @WebMaestro.Fr - That worked for me!!!!!!

Topic Closed

This topic has been closed to new replies.

About this Topic