• Resolved travaudoma

    (@travaudoma)


    i moved kernel files wordpress to a subfolder
    now have a folder “content” and “kernel” at root
    and got some problems
    some commands only work with subfolder “kernel”
    for example…
    i use this function for to add changetime for name js and css

    function put_modified_time_version($src, $baseUrl){
        if ($src && strpos($src, $baseUrl) === 0) {
            $newSrc = remove_query_arg('ver', $src);
            $path = substr($newSrc, strlen($baseUrl));
            $path = wp_parse_url($path, PHP_URL_PATH);
            if ($mtime = @filemtime(untrailingslashit(ABSPATH) . $path)) {
                $src = add_query_arg('ver', $mtime, $newSrc);
            }
        }
        return $src;
    }
    add_filter('style_loader_src', 'modified_time_version_style', 15, 1);
    function modified_time_version_style($src) {
        return ($src) ? put_modified_time_version($src, wp_styles()->base_url) : $src;
    }
    add_filter('script_loader_src', 'modified_time_version_script', 15, 1);
    function modified_time_version_script($src) {
        return ($src) ? put_modified_time_version($src, wp_scripts()->base_url) : $src;
    }

    this works only for js and css in “kernel” folder

    function work from a folder “content”
    think that a problem with $url = substr($newSrc, strlen($baseUrl));
    tell me how it is better to specify it correctly so that everything would work?

    • This topic was modified 3 years, 2 months ago by travaudoma.
Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    WP is not designed to utilize that sort of folder structure. WP can reside in a subfolder, but your code using WP resources should reside in a theme, child theme, or plugin; all of which reside in /wp-content/. You’ll have continuing path issues with the structure you are attempting.

    What you can do is move the entire /wp-content/ structure and have it reside elsewhere. See https://www.ads-software.com/support/article/editing-wp-config-php/#moving-wp-content-folder

    You’ll see in subsequent sections of that link that most folders directly below /wp-content/ can also be similarly moved.

Viewing 1 replies (of 1 total)
  • The topic ‘problem with paths wordpress in subfolder’ is closed to new replies.