:warning: For an improved BootStrap V5 version go here: https://github.com/RelevanceDigital/wp-bs-starter-theme
A basic Bootstrap 4 Wordpress theme based on underscores.
npm install --global gulp-cli
Renaming functions and files:
'_s'
(inside single quotations) to capture the text domain._s_
to capture all the function names.Text Domain: _s
in style.css
. _s
(with a space before it) to capture DocBlocks._s-
to capture prefixed handles.'_s/block-filters'
in js/gutenberg.js
Then, update the stylesheet header in style.css
, the links in footer.php
with your own information and rename _s.pot
from languages
folder to use the theme's slug. Next, update or delete this readme.
Installation
gulpfile.js
and update the browserSync proxy location to your localhost pathnpm install
to install dependenciesgulp install
to copy library scss files into the main scss foldergulp
to generate compiled assets and watch foldersEnable Errors
Whilst in development, it's best practice to enable error messages so that issues can be fixed as they arise.
Edit the wp-config.php file in the root of your site and modify the debug lines to:
//define('WP_DEBUG', false);
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', true);
@ini_set('display_errors', 1);
Running gulp install
copies the main bootstrap.scss file from node_modules
into the scss folder. It replaces the paths to imported files and imports _custom.scss
to override default variables.
The original variables file is also copied into the scss
folder as _variables-reference.scss
.
style.scss
imports bootstrap.scss
. style.scss is the file to add your custom scss to.
When running gulp
, any changes to files in the scss
folder will regenerate the compiled css files in assets/css
(compressed) and css
(nested).
To add your own scss files, add them to the scss
folder without a _
prefix.
Only minimal underscores styles are imported but the original files are left here if you need to include anything else.
All styles are enqueued in functions.php
.
Adding or editing files in the js
folder whilst running gulp
will compile them to the assets/js
folder.
Bootstrap and Fontawesome are loaded from a cdn.
All scripts are enqueued in functions.php
.
Any images added to the images
folder whilst running gulp
are automatically compressed and added to the assets/images
folder.
2 compression types are available. If the default imagescompress
reduces the quality of your images you can use imagesreduced
by changing the watch
task in gulpfile.js
.
Custom functions are added in inc/template-functions.php
.
This contains modified versions of Underscores functions as well as new ones:
If you want to enable emoji scripts or oembed, this is the place to look.
Any issues and pull requests for bugs are welcome.
If you want others to work on styling without needing to know WordPress, there is a standalone theme which uses the same structure at [https://github.com/RelevanceDigital/wp-bs4-starter-theme-standalone]()