Skip to content

Resources

John Fazioli edited this page Jan 25, 2019 · 2 revisions

Resources

In the resources folder you can start to edit the file for your theme. First of all, you may edit the wp_footer.php and the wp_head-php files.

πŸ“‚ resources
 β”œ wp_footer.php
 β”œ wp_head.php

The wp_footer.php file will be included on the wp_footer hook. In the same way, the wp_head.php will be included on the wp_head hook. They are empty for default. For example, if you need to add some meta tag in the head of page, you can add you code directly in the wp_head.php file.

<?php
/**
 * This file is included in the wp_head() hook.
 *
 * Add here your head includes. For example
 *
 * <meta name="viewport" content="width=device-width, initial-scale=1.0">
 *
 */
?>
<meta name="viewport" content="width=device-width, initial-scale=1.0">

In addition, remember that you may use spock() function to get the instance of WP Spock theme. Of course, you may use also any PHP statements.

<?php
/**
 * This file is included in the wp_head() hook.
 *
 * Add here your head includes. For example
 *
 * <meta name="viewport" content="width=device-width, initial-scale=1.0">
 *
 */
if(spock()->Version === '1.0.0') : ?>
    <meta name="version" content="ok"/>
<?php endif;    

Assets

Usually, you'll use the assets forlder for your Javascript and LESS file. WP Spock comes with a configuration to compile LESS files. Anyway, feel free to configure your package.json and your environment how you wish.

πŸ“‚ resources
 β”œπŸ“‚ assets
 | β”œπŸ“‚ images            --> put your images here
 | β”œπŸ“‚ js                --> js watcher
 | β”œπŸ“‚ less              --> less watcher

To compile the assets just run yarn watch in your terminal.

Views

The most important files, I mean, the core of the theme, is in the views folder. In fact, you won't have to edit the usual file on the root of the theme. You'll use the files in the views folder.

πŸ“‚ resources
 β”œπŸ“‚ views
 | β”œπŸ“‚ errors
 | | β”œ 404.php
 | β”œπŸ“‚ footer
 | | β”œ entry-footer.php
 | | β”œ footer.php
 | | β”œ index.php
 | β”œπŸ“‚ header
 | | β”œ entry-header.php
 | | β”œ header.php
 | | β”œ index.php
 | β”œπŸ“‚ main
 |   β”œ πŸ“‚ content
 |   β”œ πŸ“‚ post
 |   β”œ archive.php
 |   β”œ comments.php
 |   β”œ index.php
 |   β”œ page.php
 |   β”œ search.php
 |   β”œ sidebar.php
 |   β”œ single.php

As you can see, WP Spock provides a better structure for the common files.

Clone this wiki locally