0
votes

I'm trying to do something simple, though I can't find an answer for this anywhere.

I have a directory /blog/ where I have wordpress installed. I'm creating a theme to handle the blog within that directory.

I have all my styles in /style/, includes in /includes/, and scripts in /scripts/. There has to be a way for me to include these files into my wordpress theme. So basically, I want to include my stylesheet that the rest of the site (non-wordpress) is using. Yes, I'm aware wordpress requires a style.css in the theme root. However, I want to use this for other things as well. Such as including my header and footer, and also my compiled external javascript.

index.php
/style/
/blog/
    /wp-content/
        /themes/
            /my-theme/
/includes/
/scripts/

Summary: How do I access style / includes / scripts directories from within the wordpress theme.

It seems like a simple enough request, but I can't find anywhere that points me in the right direction. Thank you in advance.

2

2 Answers

1
votes

In your functions.php you can do the following:

function yourtheme_enqueue_scripts() {
  wp_enqueue_style( 'unique-id', $_SERVER['DOCUMENT_ROOT'] . '/styles/style.css', false );
  wp_enqueue_script( 'unique-id', $_SERVER['DOCUMENT_ROOT'] . '/scripts/filename.js', false );
}
add_action('wp_enqueue_scripts','yourtheme_enqueue_scripts');

Replace yourtheme, unique-id, style.css, filename.js with whatever is suitable for your situation.

0
votes

The easiest way is to use a symlink inside the Wordpress directory that points to the file outside of it.